compiler/middle/lint: Suggest #[expect(dead_code)] as alternative to #[allow(dead_code)]

This commit is contained in:
Tobias Bieniek
2025-10-15 09:36:04 +02:00
parent 4d43e78082
commit 86cef2ff98
3 changed files with 12 additions and 5 deletions
+10 -3
View File
@@ -265,9 +265,16 @@ fn explain_lint_level_source(
"`{flag} {hyphen_case_lint_name}` implied by `{flag} {hyphen_case_flag_val}`"
));
if matches!(orig_level, Level::Warn | Level::Deny) {
err.help_once(format!(
"to override `{flag} {hyphen_case_flag_val}` add `#[allow({name})]`"
));
let help = if name == "dead_code" {
format!(
"to override `{flag} {hyphen_case_flag_val}` add `#[expect({name})]` or `#[allow({name})]`"
)
} else {
format!(
"to override `{flag} {hyphen_case_flag_val}` add `#[allow({name})]`"
)
};
err.help_once(help);
}
}
}