Skip to content

Commit

Permalink
also test non-extern uninhabited statics
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Oct 25, 2020
1 parent 5d62492 commit 3bd5cc9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/test/ui/statics/uninhabited-static.rs
Expand Up @@ -9,4 +9,9 @@ extern {
//~| 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() {}
22 changes: 21 additions & 1 deletion src/test/ui/statics/uninhabited-static.stderr
Expand Up @@ -23,5 +23,25 @@ LL | static NEVER: !;
= 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
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

0 comments on commit 3bd5cc9

Please sign in to comment.