From 3bd5cc900c55722c38cf5aa51793cc133c8d741a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 25 Oct 2020 15:01:32 +0100 Subject: [PATCH] also test non-extern uninhabited statics --- src/test/ui/statics/uninhabited-static.rs | 5 +++++ src/test/ui/statics/uninhabited-static.stderr | 22 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/test/ui/statics/uninhabited-static.rs b/src/test/ui/statics/uninhabited-static.rs index 61189b0e0cd2a..cc78f6cfa53f7 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 475578b3e7c76..5d95b29993827 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 = 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 + = 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 + = note: uninhabited statics cannot be initialized, and any access would be an immediate error + +error: aborting due to 4 previous errors