diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index f62e406692a..037f84f476f 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -225,6 +225,9 @@ pub fn explain_lint_level_source( err.note_once(format!( "`{flag} {hyphen_case_lint_name}` implied by `{flag} {hyphen_case_flag_val}`" )); + err.help_once(format!( + "to override `{flag} {hyphen_case_flag_val}` add `#[allow({name})]`" + )); } } LintLevelSource::Node { name: lint_attr_name, span, reason, .. } => { diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr index 20486d596d9..6e17bbde021 100644 --- a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr +++ b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr @@ -13,6 +13,7 @@ LL | fn lintme() { } | ^^^^^^^^^^^^^^^ | = note: `-D test-lint` implied by `-D lint-me` + = help: to override `-D lint-me` add `#[allow(test_lint)]` error: item is named 'pleaselintme' --> $DIR/lint-group-plugin-deny-cmdline.rs:12:1 @@ -21,6 +22,7 @@ LL | fn pleaselintme() { } | ^^^^^^^^^^^^^^^^^^^^^ | = note: `-D please-lint` implied by `-D lint-me` + = help: to override `-D lint-me` add `#[allow(please_lint)]` error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr index 8c876213ae0..e014fc8c693 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr @@ -23,7 +23,7 @@ LL | arg: NotIntoDiagnosticArg, | = help: normalized in stderr note: required by a bound in `Diagnostic::set_arg` - --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:960:5 + --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:968:5 error: aborting due to 2 previous errors diff --git a/tests/ui/derive-uninhabited-enum-38885.stderr b/tests/ui/derive-uninhabited-enum-38885.stderr index dcdf8f8430f..3fabf446dc3 100644 --- a/tests/ui/derive-uninhabited-enum-38885.stderr +++ b/tests/ui/derive-uninhabited-enum-38885.stderr @@ -9,6 +9,7 @@ LL | Void(Void), | = note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis = note: `-W dead-code` implied by `-W unused` + = help: to override `-W unused` add `#[allow(dead_code)]` warning: 1 warning emitted diff --git a/tests/ui/lint-group-forbid-always-trumps-cli.stderr b/tests/ui/lint-group-forbid-always-trumps-cli.stderr index 8910af87ca2..cd042179cce 100644 --- a/tests/ui/lint-group-forbid-always-trumps-cli.stderr +++ b/tests/ui/lint-group-forbid-always-trumps-cli.stderr @@ -5,6 +5,7 @@ LL | let x = 1; | ^ help: if this is intentional, prefix it with an underscore: `_x` | = note: `-F unused-variables` implied by `-F unused` + = help: to override `-F unused` add `#[allow(unused_variables)]` error: aborting due to previous error diff --git a/tests/ui/lint/command-line-lint-group-deny.stderr b/tests/ui/lint/command-line-lint-group-deny.stderr index 04c3f6f2637..59d8429ea69 100644 --- a/tests/ui/lint/command-line-lint-group-deny.stderr +++ b/tests/ui/lint/command-line-lint-group-deny.stderr @@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing` | = note: `-D non-snake-case` implied by `-D bad-style` + = help: to override `-D bad-style` add `#[allow(non_snake_case)]` error: aborting due to previous error diff --git a/tests/ui/lint/command-line-lint-group-forbid.stderr b/tests/ui/lint/command-line-lint-group-forbid.stderr index 73678214063..486d32a9f08 100644 --- a/tests/ui/lint/command-line-lint-group-forbid.stderr +++ b/tests/ui/lint/command-line-lint-group-forbid.stderr @@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing` | = note: `-F non-snake-case` implied by `-F bad-style` + = help: to override `-F bad-style` add `#[allow(non_snake_case)]` error: aborting due to previous error diff --git a/tests/ui/lint/command-line-lint-group-warn.stderr b/tests/ui/lint/command-line-lint-group-warn.stderr index e9c80b4ef21..cfe346a5bf6 100644 --- a/tests/ui/lint/command-line-lint-group-warn.stderr +++ b/tests/ui/lint/command-line-lint-group-warn.stderr @@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing` | = note: `-W non-snake-case` implied by `-W bad-style` + = help: to override `-W bad-style` add `#[allow(non_snake_case)]` warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr index d1b764b3414..01c2ed84c63 100644 --- a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr @@ -7,6 +7,7 @@ LL | 0...100 => true, = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn ellipsis-inclusive-range-patterns` implied by `--force-warn rust-2021-compatibility` + = help: to override `--force-warn rust-2021-compatibility` add `#[allow(ellipsis_inclusive_range_patterns)]` warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr b/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr index dc7b1b7b98d..e925a195fb1 100644 --- a/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr +++ b/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr @@ -5,6 +5,7 @@ LL | pub fn FUNCTION() {} | ^^^^^^^^ help: convert the identifier to snake case: `function` | = note: `--force-warn non-snake-case` implied by `--force-warn nonstandard-style` + = help: to override `--force-warn nonstandard-style` add `#[allow(non_snake_case)]` warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr index e17630fd358..b0cd3ddd26f 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr @@ -7,6 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` + = help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]` help: use `dyn` | LL | pub fn function(_x: Box) {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr index 72198541a70..8c841916c93 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr @@ -7,6 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` + = help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]` help: use `dyn` | LL | pub fn function(_x: Box) {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr index 52c870ac28a..c0144205d6a 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr @@ -7,6 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` + = help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]` help: use `dyn` | LL | pub fn function(_x: Box) {} diff --git a/tests/ui/lint/future-incompat-test.stderr b/tests/ui/lint/future-incompat-test.stderr index 52674a84384..2951f904fb5 100644 --- a/tests/ui/lint/future-incompat-test.stderr +++ b/tests/ui/lint/future-incompat-test.stderr @@ -6,4 +6,5 @@ LL | let x = 1; | ^ help: if this is intentional, prefix it with an underscore: `_x` | = note: `-A unused-variables` implied by `-A unused` + = help: to override `-A unused` add `#[allow(unused_variables)]` diff --git a/tests/ui/lint/lint-pre-expansion-extern-module.stderr b/tests/ui/lint/lint-pre-expansion-extern-module.stderr index ce3e8806a9e..8a6e1531d5f 100644 --- a/tests/ui/lint/lint-pre-expansion-extern-module.stderr +++ b/tests/ui/lint/lint-pre-expansion-extern-module.stderr @@ -7,6 +7,7 @@ LL | pub fn try() {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #49716 = note: `-W keyword-idents` implied by `-W rust-2018-compatibility` + = help: to override `-W rust-2018-compatibility` add `#[allow(keyword_idents)]` warning: 1 warning emitted diff --git a/tests/ui/macros/must-use-in-macro-55516.stderr b/tests/ui/macros/must-use-in-macro-55516.stderr index 8878b0eea0f..7bf4aaab51c 100644 --- a/tests/ui/macros/must-use-in-macro-55516.stderr +++ b/tests/ui/macros/must-use-in-macro-55516.stderr @@ -6,6 +6,7 @@ LL | write!(&mut example, "{}", 42); | = note: this `Result` may be an `Err` variant, which should be handled = note: `-W unused-must-use` implied by `-W unused` + = help: to override `-W unused` add `#[allow(unused_must_use)]` = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) warning: 1 warning emitted