Skip to content

Commit efbe445

Browse files
committed
Add help to allow lint for the implied by suggestion
1 parent eba5b44 commit efbe445

16 files changed

+19
-1
lines changed

compiler/rustc_middle/src/lint.rs

+3
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ pub fn explain_lint_level_source(
225225
err.note_once(format!(
226226
"`{flag} {hyphen_case_lint_name}` implied by `{flag} {hyphen_case_flag_val}`"
227227
));
228+
err.help_once(format!(
229+
"to override `{flag} {hyphen_case_flag_val}` add `#[allow({name})]`"
230+
));
228231
}
229232
}
230233
LintLevelSource::Node { name: lint_attr_name, span, reason, .. } => {

tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ LL | fn lintme() { }
1313
| ^^^^^^^^^^^^^^^
1414
|
1515
= note: `-D test-lint` implied by `-D lint-me`
16+
= help: to override `-D lint-me` add `#[allow(test_lint)]`
1617

1718
error: item is named 'pleaselintme'
1819
--> $DIR/lint-group-plugin-deny-cmdline.rs:12:1
@@ -21,6 +22,7 @@ LL | fn pleaselintme() { }
2122
| ^^^^^^^^^^^^^^^^^^^^^
2223
|
2324
= note: `-D please-lint` implied by `-D lint-me`
25+
= help: to override `-D lint-me` add `#[allow(please_lint)]`
2426

2527
error: aborting due to 2 previous errors; 1 warning emitted
2628

tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LL | arg: NotIntoDiagnosticArg,
2323
|
2424
= help: normalized in stderr
2525
note: required by a bound in `Diagnostic::set_arg`
26-
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:960:5
26+
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:968:5
2727

2828
error: aborting due to 2 previous errors
2929

tests/ui/derive-uninhabited-enum-38885.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LL | Void(Void),
99
|
1010
= note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
1111
= note: `-W dead-code` implied by `-W unused`
12+
= help: to override `-W unused` add `#[allow(dead_code)]`
1213

1314
warning: 1 warning emitted
1415

tests/ui/lint-group-forbid-always-trumps-cli.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let x = 1;
55
| ^ help: if this is intentional, prefix it with an underscore: `_x`
66
|
77
= note: `-F unused-variables` implied by `-F unused`
8+
= help: to override `-F unused` add `#[allow(unused_variables)]`
89

910
error: aborting due to previous error
1011

tests/ui/lint/command-line-lint-group-deny.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
66
|
77
= note: `-D non-snake-case` implied by `-D bad-style`
8+
= help: to override `-D bad-style` add `#[allow(non_snake_case)]`
89

910
error: aborting due to previous error
1011

tests/ui/lint/command-line-lint-group-forbid.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
66
|
77
= note: `-F non-snake-case` implied by `-F bad-style`
8+
= help: to override `-F bad-style` add `#[allow(non_snake_case)]`
89

910
error: aborting due to previous error
1011

tests/ui/lint/command-line-lint-group-warn.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
66
|
77
= note: `-W non-snake-case` implied by `-W bad-style`
8+
= help: to override `-W bad-style` add `#[allow(non_snake_case)]`
89

910
warning: 1 warning emitted
1011

tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LL | 0...100 => true,
77
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
88
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
99
= note: `--force-warn ellipsis-inclusive-range-patterns` implied by `--force-warn rust-2021-compatibility`
10+
= help: to override `--force-warn rust-2021-compatibility` add `#[allow(ellipsis_inclusive_range_patterns)]`
1011

1112
warning: 1 warning emitted
1213

tests/ui/lint/force-warn/lint-group-allow-warnings.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | pub fn FUNCTION() {}
55
| ^^^^^^^^ help: convert the identifier to snake case: `function`
66
|
77
= note: `--force-warn non-snake-case` implied by `--force-warn nonstandard-style`
8+
= help: to override `--force-warn nonstandard-style` add `#[allow(non_snake_case)]`
89

910
warning: 1 warning emitted
1011

tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
77
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
88
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
99
= note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms`
10+
= help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]`
1011
help: use `dyn`
1112
|
1213
LL | pub fn function(_x: Box<dyn SomeTrait>) {}

tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
77
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
88
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
99
= note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms`
10+
= help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]`
1011
help: use `dyn`
1112
|
1213
LL | pub fn function(_x: Box<dyn SomeTrait>) {}

tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
77
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
88
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
99
= note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms`
10+
= help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]`
1011
help: use `dyn`
1112
|
1213
LL | pub fn function(_x: Box<dyn SomeTrait>) {}

tests/ui/lint/future-incompat-test.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ LL | let x = 1;
66
| ^ help: if this is intentional, prefix it with an underscore: `_x`
77
|
88
= note: `-A unused-variables` implied by `-A unused`
9+
= help: to override `-A unused` add `#[allow(unused_variables)]`
910

tests/ui/lint/lint-pre-expansion-extern-module.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LL | pub fn try() {}
77
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
88
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
99
= note: `-W keyword-idents` implied by `-W rust-2018-compatibility`
10+
= help: to override `-W rust-2018-compatibility` add `#[allow(keyword_idents)]`
1011

1112
warning: 1 warning emitted
1213

tests/ui/macros/must-use-in-macro-55516.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | write!(&mut example, "{}", 42);
66
|
77
= note: this `Result` may be an `Err` variant, which should be handled
88
= note: `-W unused-must-use` implied by `-W unused`
9+
= help: to override `-W unused` add `#[allow(unused_must_use)]`
910
= note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
1011

1112
warning: 1 warning emitted

0 commit comments

Comments
 (0)