Add help to allow lint for the implied by suggestion

This commit is contained in:
Urgau 2023-07-25 19:40:04 +02:00
parent eba5b44729
commit efbe445ba7
16 changed files with 19 additions and 1 deletions

View File

@ -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, .. } => {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= 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

View File

@ -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

View File

@ -7,6 +7,7 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= 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<dyn SomeTrait>) {}

View File

@ -7,6 +7,7 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= 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<dyn SomeTrait>) {}

View File

@ -7,6 +7,7 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= 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<dyn SomeTrait>) {}

View File

@ -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)]`

View File

@ -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 <https://github.com/rust-lang/rust/issues/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

View File

@ -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