Skip to content

Commit dae1d97

Browse files
committed
Make some lints incremental.
1 parent 21e9336 commit dae1d97

File tree

7 files changed

+68
-36
lines changed

7 files changed

+68
-36
lines changed

compiler/rustc_lint/src/lib.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,28 +159,16 @@ macro_rules! late_lint_passes {
159159
$macro!(
160160
$args,
161161
[
162-
// FIXME: Look into regression when this is used as a module lint
163-
// May Depend on constants elsewhere
164-
UnusedBrokenConst: UnusedBrokenConst,
165-
// Needs to run after UnusedAttributes as it marks all `feature` attributes as used.
166-
UnstableFeatures: UnstableFeatures,
167162
// Tracks state across modules
168163
UnnameableTestItems: UnnameableTestItems::new(),
169164
// Tracks attributes of parents
170165
MissingDoc: MissingDoc::new(),
171-
// Depends on access levels
166+
// Builds a global list of all impls of `Debug`.
172167
// FIXME: Turn the computation of types which implement Debug into a query
173168
// and change this to a module lint pass
174169
MissingDebugImplementations: MissingDebugImplementations::default(),
175-
ArrayIntoIter: ArrayIntoIter::default(),
170+
// Keeps a global list of foreign declarations.
176171
ClashingExternDeclarations: ClashingExternDeclarations::new(),
177-
DropTraitConstraints: DropTraitConstraints,
178-
TemporaryCStringAsPtr: TemporaryCStringAsPtr,
179-
NonPanicFmt: NonPanicFmt,
180-
NoopMethodCall: NoopMethodCall,
181-
EnumIntrinsicsNonEnums: EnumIntrinsicsNonEnums,
182-
InvalidAtomicOrdering: InvalidAtomicOrdering,
183-
NamedAsmLabels: NamedAsmLabels,
184172
]
185173
);
186174
};
@@ -216,6 +204,17 @@ macro_rules! late_lint_mod_passes {
216204
ExplicitOutlivesRequirements: ExplicitOutlivesRequirements,
217205
InvalidValue: InvalidValue,
218206
DerefNullPtr: DerefNullPtr,
207+
// May Depend on constants elsewhere
208+
UnusedBrokenConst: UnusedBrokenConst,
209+
UnstableFeatures: UnstableFeatures,
210+
ArrayIntoIter: ArrayIntoIter::default(),
211+
DropTraitConstraints: DropTraitConstraints,
212+
TemporaryCStringAsPtr: TemporaryCStringAsPtr,
213+
NonPanicFmt: NonPanicFmt,
214+
NoopMethodCall: NoopMethodCall,
215+
EnumIntrinsicsNonEnums: EnumIntrinsicsNonEnums,
216+
InvalidAtomicOrdering: InvalidAtomicOrdering,
217+
NamedAsmLabels: NamedAsmLabels,
219218
]
220219
);
221220
};

src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
warning: the type `!` does not permit zero-initialization
2+
--> $DIR/validate_uninhabited_zsts.rs:4:14
3+
|
4+
LL | unsafe { std::mem::transmute(()) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| this code causes undefined behavior when executed
8+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
9+
|
10+
= note: `#[warn(invalid_value)]` on by default
11+
= note: the `!` type has no valid value
12+
113
error[E0080]: evaluation of constant value failed
214
--> $DIR/validate_uninhabited_zsts.rs:4:14
315
|
@@ -19,18 +31,6 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
1931
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
2032
= note: the raw bytes of the constant (size: 0, align: 1) {}
2133

22-
warning: the type `!` does not permit zero-initialization
23-
--> $DIR/validate_uninhabited_zsts.rs:4:14
24-
|
25-
LL | unsafe { std::mem::transmute(()) }
26-
| ^^^^^^^^^^^^^^^^^^^^^^^
27-
| |
28-
| this code causes undefined behavior when executed
29-
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
30-
|
31-
= note: `#[warn(invalid_value)]` on by default
32-
= note: the `!` type has no valid value
33-
3434
warning: the type `empty::Empty` does not permit zero-initialization
3535
--> $DIR/validate_uninhabited_zsts.rs:23:42
3636
|

src/test/ui/consts/recursive-zst-static.default.stderr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ note: ...which requires const-evaluating + checking `FOO`...
1010
LL | static FOO: () = FOO;
1111
| ^^^
1212
= note: ...which again requires const-evaluating + checking `FOO`, completing the cycle
13-
= note: cycle used when running analysis passes on this crate
13+
note: cycle used when linting top-level module
14+
--> $DIR/recursive-zst-static.rs:10:1
15+
|
16+
LL | / static FOO: () = FOO;
17+
LL | |
18+
LL | | fn main() {
19+
LL | | FOO
20+
LL | | }
21+
| |_^
1422

1523
error: aborting due to previous error
1624

src/test/ui/consts/recursive-zst-static.unleash.stderr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ note: ...which requires const-evaluating + checking `FOO`...
1010
LL | static FOO: () = FOO;
1111
| ^^^
1212
= note: ...which again requires const-evaluating + checking `FOO`, completing the cycle
13-
= note: cycle used when running analysis passes on this crate
13+
note: cycle used when linting top-level module
14+
--> $DIR/recursive-zst-static.rs:10:1
15+
|
16+
LL | / static FOO: () = FOO;
17+
LL | |
18+
LL | | fn main() {
19+
LL | | FOO
20+
LL | | }
21+
| |_^
1422

1523
error: aborting due to previous error
1624

src/test/ui/consts/write-to-static-mut-in-static.stderr

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ note: ...which requires const-evaluating + checking `C`...
1616
LL | pub static mut C: u32 = unsafe { C = 1; 0 };
1717
| ^^^^^
1818
= note: ...which again requires const-evaluating + checking `C`, completing the cycle
19-
= note: cycle used when running analysis passes on this crate
19+
note: cycle used when linting top-level module
20+
--> $DIR/write-to-static-mut-in-static.rs:1:1
21+
|
22+
LL | / pub static mut A: u32 = 0;
23+
LL | | pub static mut B: () = unsafe { A = 1; };
24+
LL | |
25+
LL | |
26+
... |
27+
LL | |
28+
LL | | fn main() {}
29+
| |____________^
2030

2131
error: aborting due to 2 previous errors
2232

src/test/ui/recursion/recursive-static-definition.stderr

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ note: ...which requires const-evaluating + checking `FOO`...
1010
LL | pub static FOO: u32 = FOO;
1111
| ^^^
1212
= note: ...which again requires const-evaluating + checking `FOO`, completing the cycle
13-
= note: cycle used when running analysis passes on this crate
13+
note: cycle used when linting top-level module
14+
--> $DIR/recursive-static-definition.rs:1:1
15+
|
16+
LL | / pub static FOO: u32 = FOO;
17+
LL | |
18+
LL | |
19+
LL | | fn main() {}
20+
| |____________^
1421

1522
error: aborting due to previous error
1623

src/test/ui/statics/uninhabited-static.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ error[E0080]: could not evaluate static initializer
4949
LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
5050
| ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
5151

52-
error[E0080]: could not evaluate static initializer
53-
--> $DIR/uninhabited-static.rs:16:32
54-
|
55-
LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
56-
| ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
57-
5852
warning: the type `Void` does not permit zero-initialization
5953
--> $DIR/uninhabited-static.rs:12:31
6054
|
@@ -67,6 +61,12 @@ LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
6761
= note: `#[warn(invalid_value)]` on by default
6862
= note: enums with no variants have no valid value
6963

64+
error[E0080]: could not evaluate static initializer
65+
--> $DIR/uninhabited-static.rs:16:32
66+
|
67+
LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
68+
| ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
69+
7070
warning: the type `Void` does not permit zero-initialization
7171
--> $DIR/uninhabited-static.rs:16:32
7272
|

0 commit comments

Comments
 (0)