diff options
Diffstat (limited to 'tests/ui/consts/const-eval/ub-enum.rs')
-rw-r--r-- | tests/ui/consts/const-eval/ub-enum.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs index 8f26d9a00..078283fbd 100644 --- a/tests/ui/consts/const-eval/ub-enum.rs +++ b/tests/ui/consts/const-eval/ub-enum.rs @@ -2,7 +2,7 @@ // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" // normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" -#![feature(never_type)] +#![feature(never_type, const_discriminant)] #![allow(invalid_value)] use std::mem; @@ -66,8 +66,8 @@ const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; // # valid discriminant for uninhabited variant -// An enum with 3 variants of which some are uninhabited -- so the uninhabited variants *do* -// have a discriminant. +// An enum with uninhabited variants but also at least 2 inhabited variants -- so the uninhabited +// variants *do* have a discriminant. enum UninhDiscriminant { A, B(!), @@ -98,5 +98,11 @@ const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem: const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; //~^ ERROR evaluation of constant value failed +const TEST_ICE_89765: () = { + // This is a regression test for https://github.com/rust-lang/rust/issues/89765. + unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; + //~^ inside `TEST_ICE_89765` +}; + fn main() { } |