Skip to content

Commit

Permalink
Rollup merge of #121049 - estebank:issue-121009, r=fmease
Browse files Browse the repository at this point in the history
Do not point at `#[allow(_)]` as the reason for compat lint triggering

Fix #121009.
  • Loading branch information
oli-obk authored Feb 14, 2024
2 parents f77870e + 24b52fd commit 9e31121
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 53 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ pub fn explain_lint_level_source(
err: &mut Diagnostic,
) {
let name = lint.name_lower();
if let Level::Allow = level {
// Do not point at `#[allow(compat_lint)]` as the reason for a compatibility lint
// triggering. (#121009)
return;
}
match src {
LintLevelSource::Default => {
err.note_once(format!("`#[{}({})]` on by default", level.as_str(), name));
Expand Down
5 changes: 0 additions & 5 deletions tests/ui/consts/issue-89088.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,4 @@ LL | FOO => todo!(),
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
= note: the traits must be derived, manual `impl`s are not sufficient
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
note: the lint level is defined here
--> $DIR/issue-89088.rs:5:10
|
LL | #![allow(indirect_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^

5 changes: 1 addition & 4 deletions tests/ui/lint/future-incompat-json-test.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{"$message_type":"future_incompat","future_incompat_report":[{"diagnostic":{"$message_type":"diagnostic","message":"unused variable: `x`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-A unused-variables` implied by `-A unused`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"to override `-A unused` add `#[allow(unused_variables)]`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"if this is intentional, prefix it with an underscore","code":null,"level":"help","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `x`
{"$message_type":"future_incompat","future_incompat_report":[{"diagnostic":{"$message_type":"diagnostic","message":"unused variable: `x`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"if this is intentional, prefix it with an underscore","code":null,"level":"help","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `x`
--> $DIR/future-incompat-json-test.rs:9:9
|
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)]`

"}}]}
3 changes: 0 additions & 3 deletions tests/ui/lint/future-incompat-test.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ warning: unused variable: `x`
|
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)]`

Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ LL | foo!(first)
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
= note: macro invocations at the end of a block are treated as expressions
= note: to ignore the value produced by the macro, add a semicolon after the invocation of `foo`
note: the lint level is defined here
--> $DIR/semicolon-in-expressions-from-macros.rs:24:13
|
LL | #[allow(semicolon_in_expressions_from_macros)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)

Future breakage diagnostic:
Expand All @@ -79,11 +74,6 @@ LL | let _ = foo!(second);
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
note: the lint level is defined here
--> $DIR/semicolon-in-expressions-from-macros.rs:29:13
|
LL | #[allow(semicolon_in_expressions_from_macros)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)

Future breakage diagnostic:
Expand All @@ -98,11 +88,6 @@ LL | let _ = foo!(third);
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
note: the lint level is defined here
--> $DIR/semicolon-in-expressions-from-macros.rs:32:13
|
LL | #[allow(semicolon_in_expressions_from_macros)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)

Future breakage diagnostic:
Expand All @@ -117,11 +102,6 @@ LL | let _ = foo!(fourth);
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
note: the lint level is defined here
--> $DIR/semicolon-in-expressions-from-macros.rs:37:13
|
LL | #[allow(semicolon_in_expressions_from_macros)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)

Future breakage diagnostic:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,4 @@ LL | if let CONSTANT = &&MyType {
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
= note: the traits must be derived, manual `impl`s are not sufficient
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
note: the lint level is defined here
--> $DIR/const-partial_eq-fallback-ice.rs:1:10
|
LL | #![allow(warnings)]
| ^^^^^^^^
= note: `#[allow(indirect_structural_match)]` implied by `#[allow(warnings)]`

10 changes: 0 additions & 10 deletions tests/ui/proc-macro/generate-mod.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
note: the lint level is defined here
--> $DIR/generate-mod.rs:30:10
|
LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info)

Future breakage diagnostic:
Expand All @@ -155,10 +150,5 @@ LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
note: the lint level is defined here
--> $DIR/generate-mod.rs:30:10
|
LL | #[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the derive macro `generate_mod::CheckDeriveLint` (in Nightly builds, run with -Z macro-backtrace for more info)

5 changes: 0 additions & 5 deletions tests/ui/traits/issue-33140-hack-boundaries.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,4 @@ LL | impl Trait0 for dyn Send {}
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484>
note: the lint level is defined here
--> $DIR/issue-33140-hack-boundaries.rs:2:10
|
LL | #![allow(order_dependent_trait_objects)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 comments on commit 9e31121

Please sign in to comment.