rustc_lint: Prevent multiple 'lint ignored' lints
Prevent multiple 'ignored unless specified at crate level' lints. The multiplication happens because we run the same lint three times: * In BuiltinCombinedEarlyLintPass * In BuiltinCombinedPreExpansionLintPass * In shallow_lint_levels_on Only run the lint one time by checking the `lint_added_lints` bool.
This commit is contained in:
parent
eef02c453f
commit
e0c626fbbc
@ -1029,7 +1029,7 @@ fn add(&mut self, attrs: &[ast::Attribute], is_crate_node: bool, source_hir_id:
|
||||
}
|
||||
}
|
||||
|
||||
if !is_crate_node {
|
||||
if self.lint_added_lints && !is_crate_node {
|
||||
for (id, &(level, ref src)) in self.current_specs().iter() {
|
||||
if !id.lint.crate_level_only {
|
||||
continue;
|
||||
|
@ -3,20 +3,14 @@
|
||||
mod foo {
|
||||
#![allow(uncommon_codepoints)]
|
||||
//~^ ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes]
|
||||
//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes]
|
||||
//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes]
|
||||
|
||||
#[allow(uncommon_codepoints)]
|
||||
//~^ ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes]
|
||||
//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes]
|
||||
//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes]
|
||||
const BAR: f64 = 0.000001;
|
||||
|
||||
}
|
||||
|
||||
#[allow(uncommon_codepoints)]
|
||||
//~^ ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes]
|
||||
//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes]
|
||||
//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes]
|
||||
fn main() {
|
||||
}
|
||||
|
@ -11,64 +11,16 @@ LL | #![deny(uncommon_codepoints, unused_attributes)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: allow(uncommon_codepoints) is ignored unless specified at crate level
|
||||
--> $DIR/crate_level_only_lint.rs:9:9
|
||||
--> $DIR/crate_level_only_lint.rs:7:9
|
||||
|
|
||||
LL | #[allow(uncommon_codepoints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: allow(uncommon_codepoints) is ignored unless specified at crate level
|
||||
--> $DIR/crate_level_only_lint.rs:17:9
|
||||
--> $DIR/crate_level_only_lint.rs:13:9
|
||||
|
|
||||
LL | #[allow(uncommon_codepoints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: allow(uncommon_codepoints) is ignored unless specified at crate level
|
||||
--> $DIR/crate_level_only_lint.rs:4:10
|
||||
|
|
||||
LL | #![allow(uncommon_codepoints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: allow(uncommon_codepoints) is ignored unless specified at crate level
|
||||
--> $DIR/crate_level_only_lint.rs:9:9
|
||||
|
|
||||
LL | #[allow(uncommon_codepoints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: allow(uncommon_codepoints) is ignored unless specified at crate level
|
||||
--> $DIR/crate_level_only_lint.rs:17:9
|
||||
|
|
||||
LL | #[allow(uncommon_codepoints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: allow(uncommon_codepoints) is ignored unless specified at crate level
|
||||
--> $DIR/crate_level_only_lint.rs:4:10
|
||||
|
|
||||
LL | #![allow(uncommon_codepoints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: allow(uncommon_codepoints) is ignored unless specified at crate level
|
||||
--> $DIR/crate_level_only_lint.rs:9:9
|
||||
|
|
||||
LL | #[allow(uncommon_codepoints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: allow(uncommon_codepoints) is ignored unless specified at crate level
|
||||
--> $DIR/crate_level_only_lint.rs:17:9
|
||||
|
|
||||
LL | #[allow(uncommon_codepoints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user