Skip to content

Commit a9b02af

Browse files
committed
Merge builtins into EarlyLintPassObjects.
This avoids calling `early_lint_node` twice. Note: one `early_lint_node` call had `!pre_expansion` for the second argument and the other had `false`. The new single call just has `!pre_expansion`. This results in a reduction of duplicate error messages in some `ui-fulldeps` tests. The order of some `ui-fulldeps` output also changes, but that doesn't matter.
1 parent 44cb4f7 commit a9b02af

12 files changed

+90
-144
lines changed

compiler/rustc_lint/src/early.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -393,36 +393,25 @@ pub fn check_ast_node<'a>(
393393
lint_store: &LintStore,
394394
registered_tools: &RegisteredTools,
395395
lint_buffer: Option<LintBuffer>,
396-
builtin_lints: impl EarlyLintPass,
396+
builtin_lints: impl EarlyLintPass + 'static,
397397
check_node: impl EarlyCheckNode<'a>,
398398
) {
399399
let passes =
400400
if pre_expansion { &lint_store.pre_expansion_passes } else { &lint_store.early_passes };
401401
let mut passes: Vec<_> = passes.iter().map(|p| (p)()).collect();
402-
let mut buffered = lint_buffer.unwrap_or_default();
402+
passes.push(Box::new(builtin_lints));
403403

404+
let mut buffered = lint_buffer.unwrap_or_default();
404405
buffered = early_lint_node(
405406
sess,
406407
!pre_expansion,
407408
lint_store,
408409
registered_tools,
409410
buffered,
410-
builtin_lints,
411+
EarlyLintPassObjects { lints: &mut passes[..] },
411412
check_node,
412413
);
413414

414-
if !passes.is_empty() {
415-
buffered = early_lint_node(
416-
sess,
417-
false,
418-
lint_store,
419-
registered_tools,
420-
buffered,
421-
EarlyLintPassObjects { lints: &mut passes[..] },
422-
check_node,
423-
);
424-
}
425-
426415
// All of the buffered lints should have been emitted at this point.
427416
// If not, that means that we somehow buffered a lint for a node id
428417
// that was not lint-checked (perhaps it doesn't exist?). This is a bug.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
2-
--> <crate attribute>:1:1
3-
|
4-
LL | plugin(lint_plugin_test)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
6-
|
7-
= note: `#[warn(deprecated)]` on by default
8-
91
warning: item is named 'lintme'
102
--> $DIR/lint-plugin-cmdline-load.rs:8:1
113
|
@@ -14,5 +6,13 @@ LL | fn lintme() { }
146
|
157
= note: `#[warn(test_lint)]` on by default
168

9+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
10+
--> <crate attribute>:1:1
11+
|
12+
LL | plugin(lint_plugin_test)
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
14+
|
15+
= note: `#[warn(deprecated)]` on by default
16+
1717
warning: 2 warnings emitted
1818

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
2-
--> $DIR/lint-plugin-deny-attr.rs:5:1
3-
|
4-
LL | #![plugin(lint_plugin_test)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
6-
|
7-
= note: `#[warn(deprecated)]` on by default
8-
91
error: item is named 'lintme'
102
--> $DIR/lint-plugin-deny-attr.rs:9:1
113
|
@@ -18,5 +10,13 @@ note: the lint level is defined here
1810
LL | #![deny(test_lint)]
1911
| ^^^^^^^^^
2012

13+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
14+
--> $DIR/lint-plugin-deny-attr.rs:5:1
15+
|
16+
LL | #![plugin(lint_plugin_test)]
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
18+
|
19+
= note: `#[warn(deprecated)]` on by default
20+
2121
error: aborting due to previous error; 1 warning emitted
2222

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
2-
--> $DIR/lint-plugin-deny-cmdline.rs:6:1
3-
|
4-
LL | #![plugin(lint_plugin_test)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
6-
|
7-
= note: `#[warn(deprecated)]` on by default
8-
91
error: item is named 'lintme'
102
--> $DIR/lint-plugin-deny-cmdline.rs:9:1
113
|
@@ -14,5 +6,13 @@ LL | fn lintme() { }
146
|
157
= note: requested on the command line with `-D test-lint`
168

9+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
10+
--> $DIR/lint-plugin-deny-cmdline.rs:6:1
11+
|
12+
LL | #![plugin(lint_plugin_test)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
14+
|
15+
= note: `#[warn(deprecated)]` on by default
16+
1717
error: aborting due to previous error; 1 warning emitted
1818

src/test/ui-fulldeps/lint-plugin-forbid-attrs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ fn lintme() {} //~ ERROR item is named 'lintme'
1111
#[allow(test_lint)]
1212
//~^ ERROR allow(test_lint) incompatible
1313
//~| ERROR allow(test_lint) incompatible
14-
//~| ERROR allow(test_lint) incompatible
1514
pub fn main() {
1615
lintme();
1716
}

src/test/ui-fulldeps/lint-plugin-forbid-attrs.stderr

+9-18
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,6 @@ LL | #![forbid(test_lint)]
77
LL | #[allow(test_lint)]
88
| ^^^^^^^^^ overruled by previous forbid
99

10-
error[E0453]: allow(test_lint) incompatible with previous forbid
11-
--> $DIR/lint-plugin-forbid-attrs.rs:11:9
12-
|
13-
LL | #![forbid(test_lint)]
14-
| --------- `forbid` level set here
15-
...
16-
LL | #[allow(test_lint)]
17-
| ^^^^^^^^^ overruled by previous forbid
18-
19-
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
20-
--> $DIR/lint-plugin-forbid-attrs.rs:5:1
21-
|
22-
LL | #![plugin(lint_plugin_test)]
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
24-
|
25-
= note: `#[warn(deprecated)]` on by default
26-
2710
error: item is named 'lintme'
2811
--> $DIR/lint-plugin-forbid-attrs.rs:9:1
2912
|
@@ -45,6 +28,14 @@ LL | #![forbid(test_lint)]
4528
LL | #[allow(test_lint)]
4629
| ^^^^^^^^^ overruled by previous forbid
4730

48-
error: aborting due to 4 previous errors; 1 warning emitted
31+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
32+
--> $DIR/lint-plugin-forbid-attrs.rs:5:1
33+
|
34+
LL | #![plugin(lint_plugin_test)]
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
36+
|
37+
= note: `#[warn(deprecated)]` on by default
38+
39+
error: aborting due to 3 previous errors; 1 warning emitted
4940

5041
For more information about this error, try `rustc --explain E0453`.

src/test/ui-fulldeps/lint-plugin-forbid-cmdline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn lintme() { } //~ ERROR item is named 'lintme'
99

1010
#[allow(test_lint)] //~ ERROR allow(test_lint) incompatible
1111
//~| ERROR allow(test_lint) incompatible
12-
//~| ERROR allow(test_lint)
12+
1313
pub fn main() {
1414
lintme();
1515
}

src/test/ui-fulldeps/lint-plugin-forbid-cmdline.stderr

+9-17
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,6 @@ LL | #[allow(test_lint)]
66
|
77
= note: `forbid` lint level was set on command line
88

9-
error[E0453]: allow(test_lint) incompatible with previous forbid
10-
--> $DIR/lint-plugin-forbid-cmdline.rs:10:9
11-
|
12-
LL | #[allow(test_lint)]
13-
| ^^^^^^^^^ overruled by previous forbid
14-
|
15-
= note: `forbid` lint level was set on command line
16-
17-
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
18-
--> $DIR/lint-plugin-forbid-cmdline.rs:6:1
19-
|
20-
LL | #![plugin(lint_plugin_test)]
21-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
22-
|
23-
= note: `#[warn(deprecated)]` on by default
24-
259
error: item is named 'lintme'
2610
--> $DIR/lint-plugin-forbid-cmdline.rs:8:1
2711
|
@@ -38,6 +22,14 @@ LL | #[allow(test_lint)]
3822
|
3923
= note: `forbid` lint level was set on command line
4024

41-
error: aborting due to 4 previous errors; 1 warning emitted
25+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
26+
--> $DIR/lint-plugin-forbid-cmdline.rs:6:1
27+
|
28+
LL | #![plugin(lint_plugin_test)]
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
30+
|
31+
= note: `#[warn(deprecated)]` on by default
32+
33+
error: aborting due to 3 previous errors; 1 warning emitted
4234

4335
For more information about this error, try `rustc --explain E0453`.
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
2-
--> $DIR/lint-plugin.rs:5:1
3-
|
4-
LL | #![plugin(lint_plugin_test)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
6-
|
7-
= note: `#[warn(deprecated)]` on by default
8-
91
warning: item is named 'lintme'
102
--> $DIR/lint-plugin.rs:8:1
113
|
@@ -14,5 +6,13 @@ LL | fn lintme() { }
146
|
157
= note: `#[warn(test_lint)]` on by default
168

9+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
10+
--> $DIR/lint-plugin.rs:5:1
11+
|
12+
LL | #![plugin(lint_plugin_test)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
14+
|
15+
= note: `#[warn(deprecated)]` on by default
16+
1717
warning: 2 warnings emitted
1818

src/test/ui-fulldeps/lint-tool-cmdline-allow.stderr

+9-13
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ warning: lint name `test_lint` is deprecated and does not have an effect anymore
66
|
77
= note: requested on the command line with `-A test_lint`
88

9-
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
10-
--> $DIR/lint-tool-cmdline-allow.rs:7:1
11-
|
12-
LL | #![plugin(lint_tool_test)]
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
14-
|
15-
= note: `#[warn(deprecated)]` on by default
16-
17-
warning: lint name `test_lint` is deprecated and does not have an effect anymore. Use: clippy::test_lint
18-
|
19-
= note: requested on the command line with `-A test_lint`
20-
219
warning: item is named 'lintme'
2210
--> $DIR/lint-tool-cmdline-allow.rs:9:1
2311
|
@@ -26,9 +14,17 @@ LL | fn lintme() {}
2614
|
2715
= note: `#[warn(clippy::test_lint)]` on by default
2816

17+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
18+
--> $DIR/lint-tool-cmdline-allow.rs:7:1
19+
|
20+
LL | #![plugin(lint_tool_test)]
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
22+
|
23+
= note: `#[warn(deprecated)]` on by default
24+
2925
warning: lint name `test_lint` is deprecated and does not have an effect anymore. Use: clippy::test_lint
3026
|
3127
= note: requested on the command line with `-A test_lint`
3228

33-
warning: 6 warnings emitted
29+
warning: 5 warnings emitted
3430

src/test/ui-fulldeps/lint-tool-test.rs

-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
//~^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future
1111
//~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future
1212
//~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future
13-
//~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future
1413
#![deny(clippy_group)]
1514
//~^ WARNING lint name `clippy_group` is deprecated and may not have an effect in the future
1615
//~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future
1716
//~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future
18-
//~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future
1917

2018
fn lintme() { } //~ ERROR item is named 'lintme'
2119

@@ -32,7 +30,6 @@ pub fn main() {
3230
//~^ WARNING lint name `test_group` is deprecated and may not have an effect in the future
3331
//~| WARNING lint name `test_group` is deprecated and may not have an effect in the future
3432
//~| WARNING lint name `test_group` is deprecated and may not have an effect in the future
35-
//~| WARNING lint name `test_group` is deprecated and may not have an effect in the future
3633
#[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist`
3734
fn hello() {
3835
fn lintmetoo() { }

0 commit comments

Comments
 (0)