forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#78324 - RalfJung:uninhabited-statics, r=oli…
…-obk ensure that statics are inhabited Fixes rust-lang#74840 r? @oli-obk
- Loading branch information
Showing
4 changed files
with
139 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![feature(never_type)] | ||
#![deny(uninhabited_static)] | ||
|
||
enum Void {} | ||
extern { | ||
static VOID: Void; //~ ERROR static of uninhabited type | ||
//~| WARN: previously accepted | ||
static NEVER: !; //~ ERROR static of uninhabited type | ||
//~| WARN: previously accepted | ||
} | ||
|
||
static VOID2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type | ||
//~| WARN: previously accepted | ||
static NEVER2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type | ||
//~| WARN: previously accepted | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
error: static of uninhabited type | ||
--> $DIR/uninhabited-static.rs:6:5 | ||
| | ||
LL | static VOID: Void; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/uninhabited-static.rs:2:9 | ||
| | ||
LL | #![deny(uninhabited_static)] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> | ||
= note: uninhabited statics cannot be initialized, and any access would be an immediate error | ||
|
||
error: static of uninhabited type | ||
--> $DIR/uninhabited-static.rs:8:5 | ||
| | ||
LL | static NEVER: !; | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> | ||
= note: uninhabited statics cannot be initialized, and any access would be an immediate error | ||
|
||
error: static of uninhabited type | ||
--> $DIR/uninhabited-static.rs:12:1 | ||
| | ||
LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> | ||
= note: uninhabited statics cannot be initialized, and any access would be an immediate error | ||
|
||
error: static of uninhabited type | ||
--> $DIR/uninhabited-static.rs:14:1 | ||
| | ||
LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> | ||
= note: uninhabited statics cannot be initialized, and any access would be an immediate error | ||
|
||
error: aborting due to 4 previous errors | ||
|