Skip to content

Commit 069723e

Browse files
committed
fix(unknown_lints): Make emitted_source come before other groups
1 parent 5ac9eb0 commit 069723e

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/cargo/util/lints.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,12 @@ fn output_unknown_lints(
535535
let help =
536536
matching.map(|(name, kind)| format!("there is a {kind} with a similar name: `{name}`"));
537537

538+
let mut footers = Vec::new();
539+
if emitted_source.is_none() {
540+
emitted_source = Some(UNKNOWN_LINTS.emitted_source(lint_level, reason));
541+
footers.push(Level::Note.title(emitted_source.as_ref().unwrap()));
542+
}
543+
538544
let mut message = if let Some(span) =
539545
get_span(manifest.document(), &["lints", "cargo", lint_name], false)
540546
{
@@ -569,25 +575,21 @@ fn output_unknown_lints(
569575
} else {
570576
Level::Note.title(&second_title)
571577
};
578+
footers.push(inherited_note);
572579

573-
level
574-
.title(&title)
575-
.snippet(
576-
Snippet::source(ws_contents)
577-
.origin(&ws_path)
578-
.annotation(Level::Error.span(lint_span))
579-
.fold(true),
580-
)
581-
.footer(inherited_note)
580+
level.title(&title).snippet(
581+
Snippet::source(ws_contents)
582+
.origin(&ws_path)
583+
.annotation(Level::Error.span(lint_span))
584+
.fold(true),
585+
)
582586
};
583587

584-
if emitted_source.is_none() {
585-
emitted_source = Some(UNKNOWN_LINTS.emitted_source(lint_level, reason));
586-
message = message.footer(Level::Note.title(emitted_source.as_ref().unwrap()));
587-
}
588-
589588
if let Some(help) = help.as_ref() {
590-
message = message.footer(Level::Help.title(help));
589+
footers.push(Level::Help.title(help));
590+
}
591+
for footer in footers {
592+
message = message.footer(footer);
591593
}
592594

593595
gctx.shell().print_message(message)?;

tests/testsuite/lints/unknown_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ workspace = true
7676
6 | this-lint-does-not-exist = "warn"
7777
| ^^^^^^^^^^^^^^^^^^^^^^^^
7878
|
79+
= [NOTE] `cargo::unknown_lints` is set to `warn` by default
7980
[NOTE] `cargo::this-lint-does-not-exist` was inherited
8081
--> foo/Cargo.toml:9:1
8182
|
8283
9 | workspace = true
8384
| ----------------
8485
|
85-
= [NOTE] `cargo::unknown_lints` is set to `warn` by default
8686
[CHECKING] foo v0.0.1 ([ROOT]/foo/foo)
8787
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
8888

0 commit comments

Comments
 (0)