Skip to content

Commit 58d676b

Browse files
committed
Remove deduplication of early lints
We already have a general mechanism for deduplicating reported lints, so there's no need to have an additional one for early lints specifically. This allows us to remove some `PartialEq` impls.
1 parent bfe1564 commit 58d676b

22 files changed

+382
-26
lines changed

compiler/rustc_lint_defs/src/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ pub enum ExternDepSpec {
282282

283283
// This could be a closure, but then implementing derive trait
284284
// becomes hacky (and it gets allocated).
285-
#[derive(PartialEq, Debug)]
285+
#[derive(Debug)]
286286
pub enum BuiltinLintDiagnostics {
287287
Normal,
288288
AbsPathWithModule(Span),
@@ -309,7 +309,6 @@ pub enum BuiltinLintDiagnostics {
309309

310310
/// Lints that are buffered up early on in the `Session` before the
311311
/// `LintLevels` is calculated.
312-
#[derive(PartialEq)]
313312
pub struct BufferedEarlyLint {
314313
/// The span of code that we are linting on.
315314
pub span: MultiSpan,
@@ -336,9 +335,7 @@ pub struct LintBuffer {
336335
impl LintBuffer {
337336
pub fn add_early_lint(&mut self, early_lint: BufferedEarlyLint) {
338337
let arr = self.map.entry(early_lint.node_id).or_default();
339-
if !arr.contains(&early_lint) {
340-
arr.push(early_lint);
341-
}
338+
arr.push(early_lint);
342339
}
343340

344341
pub fn add_lint(

src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs

+4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
#![cfg_attr(foo, crate_type="bin")]
66
//~^ERROR `crate_type` within
77
//~| WARN this was previously accepted
8+
//~|ERROR `crate_type` within
9+
//~| WARN this was previously accepted
810
#![cfg_attr(foo, crate_name="bar")]
911
//~^ERROR `crate_name` within
1012
//~| WARN this was previously accepted
13+
//~|ERROR `crate_name` within
14+
//~| WARN this was previously accepted
1115

1216
fn main() {}

src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.stderr

+20-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,31 @@ LL | #![deny(warnings)]
1414
= note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632>
1515

1616
error: `crate_name` within an `#![cfg_attr] attribute is deprecated`
17-
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:8:18
17+
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:10:18
1818
|
1919
LL | #![cfg_attr(foo, crate_name="bar")]
2020
| ^^^^^^^^^^^^^^^^
2121
|
2222
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2323
= note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632>
2424

25-
error: aborting due to 2 previous errors
25+
error: `crate_type` within an `#![cfg_attr] attribute is deprecated`
26+
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:5:18
27+
|
28+
LL | #![cfg_attr(foo, crate_type="bin")]
29+
| ^^^^^^^^^^^^^^^^
30+
|
31+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
32+
= note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632>
33+
34+
error: `crate_name` within an `#![cfg_attr] attribute is deprecated`
35+
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:10:18
36+
|
37+
LL | #![cfg_attr(foo, crate_name="bar")]
38+
| ^^^^^^^^^^^^^^^^
39+
|
40+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
41+
= note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632>
42+
43+
error: aborting due to 4 previous errors
2644

src/test/ui/proc-macro/issue-73933-procedural-masquerade.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
extern crate test_macros;
55

66
#[derive(Print)]
7-
enum ProceduralMasqueradeDummyType { //~ ERROR using
7+
enum ProceduralMasqueradeDummyType {
8+
//~^ ERROR using
9+
//~| WARN this was previously
10+
//~| ERROR using
11+
//~| WARN this was previously
12+
//~| ERROR using
13+
//~| WARN this was previously
14+
//~| ERROR using
815
//~| WARN this was previously
916
Input
1017
}

src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr

+64-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,37 @@ LL | enum ProceduralMasqueradeDummyType {
99
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
1010
= note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling.
1111

12-
error: aborting due to previous error
12+
error: using `procedural-masquerade` crate
13+
--> $DIR/issue-73933-procedural-masquerade.rs:7:6
14+
|
15+
LL | enum ProceduralMasqueradeDummyType {
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
|
18+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
19+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
20+
= note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling.
21+
22+
error: using `procedural-masquerade` crate
23+
--> $DIR/issue-73933-procedural-masquerade.rs:7:6
24+
|
25+
LL | enum ProceduralMasqueradeDummyType {
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
|
28+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
29+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
30+
= note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling.
31+
32+
error: using `procedural-masquerade` crate
33+
--> $DIR/issue-73933-procedural-masquerade.rs:7:6
34+
|
35+
LL | enum ProceduralMasqueradeDummyType {
36+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37+
|
38+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
39+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
40+
= note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling.
41+
42+
error: aborting due to 4 previous errors
1343

1444
Future incompatibility report: Future breakage diagnostic:
1545
error: using `procedural-masquerade` crate
@@ -23,3 +53,36 @@ LL | enum ProceduralMasqueradeDummyType {
2353
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
2454
= note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling.
2555

56+
Future breakage diagnostic:
57+
error: using `procedural-masquerade` crate
58+
--> $DIR/issue-73933-procedural-masquerade.rs:7:6
59+
|
60+
LL | enum ProceduralMasqueradeDummyType {
61+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62+
|
63+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
64+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
65+
= note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling.
66+
67+
Future breakage diagnostic:
68+
error: using `procedural-masquerade` crate
69+
--> $DIR/issue-73933-procedural-masquerade.rs:7:6
70+
|
71+
LL | enum ProceduralMasqueradeDummyType {
72+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73+
|
74+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
75+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
76+
= note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling.
77+
78+
Future breakage diagnostic:
79+
error: using `procedural-masquerade` crate
80+
--> $DIR/issue-73933-procedural-masquerade.rs:7:6
81+
|
82+
LL | enum ProceduralMasqueradeDummyType {
83+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
84+
|
85+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
86+
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
87+
= note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling.
88+

src/test/ui/proc-macro/issue-73933-procedural-masquerade.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
1414
stream: TokenStream [
1515
Ident {
1616
ident: "Input",
17-
span: #0 bytes(173..178),
17+
span: #0 bytes(315..320),
1818
},
1919
],
20-
span: #0 bytes(121..180),
20+
span: #0 bytes(121..322),
2121
},
2222
]

src/test/ui/proc-macro/issue-75930-derive-cfg.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,17 @@ LL | #[derive(Print)]
1111
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1212
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
1313

14-
warning: 1 warning emitted
14+
warning: derive helper attribute is used before it is introduced
15+
--> $DIR/issue-75930-derive-cfg.rs:19:3
16+
|
17+
LL | #[print_helper(a)]
18+
| ^^^^^^^^^^^^
19+
...
20+
LL | #[derive(Print)]
21+
| ----- the attribute is introduced here
22+
|
23+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
24+
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
25+
26+
warning: 2 warnings emitted
1527

src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed

+14
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,28 @@ crate mod foo {
1717
use crate::foo::{bar::{baz::{}}};
1818
//~^ ERROR absolute paths must start with
1919
//~| WARN this is accepted in the current edition
20+
//~| ERROR absolute paths must start with
21+
//~| WARN this is accepted in the current edition
2022

2123
use crate::foo::{bar::{XX, baz::{}}};
2224
//~^ ERROR absolute paths must start with
2325
//~| WARN this is accepted in the current edition
26+
//~| ERROR absolute paths must start with
27+
//~| WARN this is accepted in the current edition
28+
//~| ERROR absolute paths must start with
29+
//~| WARN this is accepted in the current edition
30+
//~| ERROR absolute paths must start with
31+
//~| WARN this is accepted in the current edition
2432

2533
use crate::foo::{bar::{baz::{}, baz1::{}}};
2634
//~^ ERROR absolute paths must start with
2735
//~| WARN this is accepted in the current edition
36+
//~| ERROR absolute paths must start with
37+
//~| WARN this is accepted in the current edition
38+
//~| ERROR absolute paths must start with
39+
//~| WARN this is accepted in the current edition
40+
//~| ERROR absolute paths must start with
41+
//~| WARN this is accepted in the current edition
2842

2943
fn main() {
3044
}

src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs

+14
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,28 @@ crate mod foo {
1717
use foo::{bar::{baz::{}}};
1818
//~^ ERROR absolute paths must start with
1919
//~| WARN this is accepted in the current edition
20+
//~| ERROR absolute paths must start with
21+
//~| WARN this is accepted in the current edition
2022

2123
use foo::{bar::{XX, baz::{}}};
2224
//~^ ERROR absolute paths must start with
2325
//~| WARN this is accepted in the current edition
26+
//~| ERROR absolute paths must start with
27+
//~| WARN this is accepted in the current edition
28+
//~| ERROR absolute paths must start with
29+
//~| WARN this is accepted in the current edition
30+
//~| ERROR absolute paths must start with
31+
//~| WARN this is accepted in the current edition
2432

2533
use foo::{bar::{baz::{}, baz1::{}}};
2634
//~^ ERROR absolute paths must start with
2735
//~| WARN this is accepted in the current edition
36+
//~| ERROR absolute paths must start with
37+
//~| WARN this is accepted in the current edition
38+
//~| ERROR absolute paths must start with
39+
//~| WARN this is accepted in the current edition
40+
//~| ERROR absolute paths must start with
41+
//~| WARN this is accepted in the current edition
2842

2943
fn main() {
3044
}

src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr

+66-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
1313
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
1414

1515
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
16-
--> $DIR/edition-lint-nested-empty-paths.rs:21:5
16+
--> $DIR/edition-lint-nested-empty-paths.rs:17:5
17+
|
18+
LL | use foo::{bar::{baz::{}}};
19+
| ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}`
20+
|
21+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
22+
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
23+
24+
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
25+
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
1726
|
1827
LL | use foo::{bar::{XX, baz::{}}};
1928
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@@ -22,13 +31,67 @@ LL | use foo::{bar::{XX, baz::{}}};
2231
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
2332

2433
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
25-
--> $DIR/edition-lint-nested-empty-paths.rs:25:5
34+
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
35+
|
36+
LL | use foo::{bar::{XX, baz::{}}};
37+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
38+
|
39+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
40+
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
41+
42+
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
43+
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
44+
|
45+
LL | use foo::{bar::{XX, baz::{}}};
46+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
47+
|
48+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
49+
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
50+
51+
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
52+
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
53+
|
54+
LL | use foo::{bar::{XX, baz::{}}};
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
56+
|
57+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
58+
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
59+
60+
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
61+
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
62+
|
63+
LL | use foo::{bar::{baz::{}, baz1::{}}};
64+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
65+
|
66+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
67+
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
68+
69+
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
70+
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
71+
|
72+
LL | use foo::{bar::{baz::{}, baz1::{}}};
73+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
74+
|
75+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
76+
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
77+
78+
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
79+
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
80+
|
81+
LL | use foo::{bar::{baz::{}, baz1::{}}};
82+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
83+
|
84+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
85+
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
86+
87+
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
88+
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
2689
|
2790
LL | use foo::{bar::{baz::{}, baz1::{}}};
2891
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
2992
|
3093
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
3194
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
3295

33-
error: aborting due to 3 previous errors
96+
error: aborting due to 10 previous errors
3497

src/test/ui/rust-2018/edition-lint-nested-paths.fixed

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
use crate::foo::{a, b};
77
//~^ ERROR absolute paths must start with
88
//~| this is accepted in the current edition
9+
//~| ERROR absolute paths must start with
10+
//~| this is accepted in the current edition
11+
//~| ERROR absolute paths must start with
12+
//~| this is accepted in the current edition
13+
//~| ERROR absolute paths must start with
14+
//~| this is accepted in the current edition
915

1016
mod foo {
1117
crate fn a() {}
@@ -21,6 +27,10 @@ fn main() {
2127
use crate::foo::{self as x, c};
2228
//~^ ERROR absolute paths must start with
2329
//~| this is accepted in the current edition
30+
//~| ERROR absolute paths must start with
31+
//~| this is accepted in the current edition
32+
//~| ERROR absolute paths must start with
33+
//~| this is accepted in the current edition
2434
x::a();
2535
c();
2636
}

src/test/ui/rust-2018/edition-lint-nested-paths.rs

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
use foo::{a, b};
77
//~^ ERROR absolute paths must start with
88
//~| this is accepted in the current edition
9+
//~| ERROR absolute paths must start with
10+
//~| this is accepted in the current edition
11+
//~| ERROR absolute paths must start with
12+
//~| this is accepted in the current edition
13+
//~| ERROR absolute paths must start with
14+
//~| this is accepted in the current edition
915

1016
mod foo {
1117
crate fn a() {}
@@ -21,6 +27,10 @@ fn main() {
2127
use foo::{self as x, c};
2228
//~^ ERROR absolute paths must start with
2329
//~| this is accepted in the current edition
30+
//~| ERROR absolute paths must start with
31+
//~| this is accepted in the current edition
32+
//~| ERROR absolute paths must start with
33+
//~| this is accepted in the current edition
2434
x::a();
2535
c();
2636
}

0 commit comments

Comments
 (0)