Skip to content

Commit 4c83028

Browse files
committed
deny-by-default & report in deps uninhabited_static
1 parent 98e7077 commit 4c83028

File tree

3 files changed

+58
-14
lines changed

3 files changed

+58
-14
lines changed

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,7 +2707,7 @@ declare_lint! {
27072707
///
27082708
/// ### Example
27092709
///
2710-
/// ```rust
2710+
/// ```rust,compile_fail
27112711
/// enum Void {}
27122712
/// unsafe extern {
27132713
/// static EXTERN: Void;
@@ -2723,10 +2723,11 @@ declare_lint! {
27232723
/// compiler which assumes that there are no initialized uninhabited places (such as locals or
27242724
/// statics). This was accidentally allowed, but is being phased out.
27252725
pub UNINHABITED_STATIC,
2726-
Warn,
2726+
Deny,
27272727
"uninhabited static",
27282728
@future_incompatible = FutureIncompatibleInfo {
27292729
reason: fcw!(FutureReleaseError #74840),
2730+
report_in_deps: true,
27302731
};
27312732
}
27322733

tests/ui/statics/uninhabited-static.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(never_type)]
2-
#![deny(uninhabited_static)]
32

43
enum Void {}
54
extern "C" {
Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
error: static of uninhabited type
2-
--> $DIR/uninhabited-static.rs:12:1
2+
--> $DIR/uninhabited-static.rs:11:1
33
|
44
LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
55
| ^^^^^^^^^^^^^^^^^^
66
|
77
= note: uninhabited statics cannot be initialized, and any access would be an immediate error
88
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
99
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
10-
note: the lint level is defined here
11-
--> $DIR/uninhabited-static.rs:2:9
12-
|
13-
LL | #![deny(uninhabited_static)]
14-
| ^^^^^^^^^^^^^^^^^^
10+
= note: `#[deny(uninhabited_static)]` (part of `#[deny(future_incompatible)]`) on by default
1511

1612
error: static of uninhabited type
17-
--> $DIR/uninhabited-static.rs:15:1
13+
--> $DIR/uninhabited-static.rs:14:1
1814
|
1915
LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
2016
| ^^^^^^^^^^^^^^^^^^^
@@ -24,7 +20,7 @@ LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
2420
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
2521

2622
error: static of uninhabited type
27-
--> $DIR/uninhabited-static.rs:6:5
23+
--> $DIR/uninhabited-static.rs:5:5
2824
|
2925
LL | static VOID: Void;
3026
| ^^^^^^^^^^^^^^^^^
@@ -34,7 +30,7 @@ LL | static VOID: Void;
3430
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
3531

3632
error: static of uninhabited type
37-
--> $DIR/uninhabited-static.rs:8:5
33+
--> $DIR/uninhabited-static.rs:7:5
3834
|
3935
LL | static NEVER: !;
4036
| ^^^^^^^^^^^^^^^
@@ -44,17 +40,65 @@ LL | static NEVER: !;
4440
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
4541

4642
error[E0080]: constructing invalid value: encountered a value of uninhabited type `Void`
47-
--> $DIR/uninhabited-static.rs:12:31
43+
--> $DIR/uninhabited-static.rs:11:31
4844
|
4945
LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
5046
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `VOID2` failed here
5147

5248
error[E0080]: constructing invalid value: encountered a value of uninhabited type `Void`
53-
--> $DIR/uninhabited-static.rs:15:32
49+
--> $DIR/uninhabited-static.rs:14:32
5450
|
5551
LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
5652
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NEVER2` failed here
5753

5854
error: aborting due to 6 previous errors
5955

6056
For more information about this error, try `rustc --explain E0080`.
57+
Future incompatibility report: Future breakage diagnostic:
58+
error: static of uninhabited type
59+
--> $DIR/uninhabited-static.rs:11:1
60+
|
61+
LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
62+
| ^^^^^^^^^^^^^^^^^^
63+
|
64+
= note: uninhabited statics cannot be initialized, and any access would be an immediate error
65+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
66+
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
67+
= note: `#[deny(uninhabited_static)]` (part of `#[deny(future_incompatible)]`) on by default
68+
69+
Future breakage diagnostic:
70+
error: static of uninhabited type
71+
--> $DIR/uninhabited-static.rs:14:1
72+
|
73+
LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
74+
| ^^^^^^^^^^^^^^^^^^^
75+
|
76+
= note: uninhabited statics cannot be initialized, and any access would be an immediate error
77+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
78+
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
79+
= note: `#[deny(uninhabited_static)]` (part of `#[deny(future_incompatible)]`) on by default
80+
81+
Future breakage diagnostic:
82+
error: static of uninhabited type
83+
--> $DIR/uninhabited-static.rs:5:5
84+
|
85+
LL | static VOID: Void;
86+
| ^^^^^^^^^^^^^^^^^
87+
|
88+
= note: uninhabited statics cannot be initialized, and any access would be an immediate error
89+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
90+
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
91+
= note: `#[deny(uninhabited_static)]` (part of `#[deny(future_incompatible)]`) on by default
92+
93+
Future breakage diagnostic:
94+
error: static of uninhabited type
95+
--> $DIR/uninhabited-static.rs:7:5
96+
|
97+
LL | static NEVER: !;
98+
| ^^^^^^^^^^^^^^^
99+
|
100+
= note: uninhabited statics cannot be initialized, and any access would be an immediate error
101+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
102+
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
103+
= note: `#[deny(uninhabited_static)]` (part of `#[deny(future_incompatible)]`) on by default
104+

0 commit comments

Comments
 (0)