Skip to content

Commit 3bd5cc9

Browse files
committed
also test non-extern uninhabited statics
1 parent 5d62492 commit 3bd5cc9

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ extern {
99
//~| WARN: previously accepted
1010
}
1111

12+
static VOID2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type
13+
//~| WARN: previously accepted
14+
static NEVER2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type
15+
//~| WARN: previously accepted
16+
1217
fn main() {}

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

+21-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,25 @@ LL | static NEVER: !;
2323
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
2424
= note: uninhabited statics cannot be initialized, and any access would be an immediate error
2525

26-
error: aborting due to 2 previous errors
26+
error: static of uninhabited type
27+
--> $DIR/uninhabited-static.rs:12:1
28+
|
29+
LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
|
32+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
33+
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
34+
= note: uninhabited statics cannot be initialized, and any access would be an immediate error
35+
36+
error: static of uninhabited type
37+
--> $DIR/uninhabited-static.rs:14:1
38+
|
39+
LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
40+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41+
|
42+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
43+
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
44+
= note: uninhabited statics cannot be initialized, and any access would be an immediate error
45+
46+
error: aborting due to 4 previous errors
2747

0 commit comments

Comments
 (0)