about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-10-25 15:01:32 +0100
committerRalf Jung <post@ralfj.de>2020-10-25 15:01:52 +0100
commit3bd5cc900c55722c38cf5aa51793cc133c8d741a (patch)
tree7e9a86cf18226e42fc5e85d6daf3569d4db31d51
parent5d624929cf194fafdb5c6a49f0bf6304010ef5ba (diff)
downloadrust-3bd5cc900c55722c38cf5aa51793cc133c8d741a.tar.gz
rust-3bd5cc900c55722c38cf5aa51793cc133c8d741a.zip
also test non-extern uninhabited statics
-rw-r--r--src/test/ui/statics/uninhabited-static.rs5
-rw-r--r--src/test/ui/statics/uninhabited-static.stderr22
2 files changed, 26 insertions, 1 deletions
diff --git a/src/test/ui/statics/uninhabited-static.rs b/src/test/ui/statics/uninhabited-static.rs
index 61189b0e0cd..cc78f6cfa53 100644
--- a/src/test/ui/statics/uninhabited-static.rs
+++ b/src/test/ui/statics/uninhabited-static.rs
@@ -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() {}
diff --git a/src/test/ui/statics/uninhabited-static.stderr b/src/test/ui/statics/uninhabited-static.stderr
index 475578b3e7c..5d95b299938 100644
--- a/src/test/ui/statics/uninhabited-static.stderr
+++ b/src/test/ui/statics/uninhabited-static.stderr
@@ -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