-
Notifications
You must be signed in to change notification settings - Fork 13.4k
ensure that statics are inhabited #78324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does the diagnostic for a regular There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, looks like it does (see the test change I just pushed)... would you prefer it to only apply to foreign items? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, having tests for it is good, I'm mostly suprised we don't have any other tests for this |
||
//~| WARN: previously accepted | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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: aborting due to 2 previous errors | ||
|
Uh oh!
There was an error while loading. Please reload this page.