From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/consts/const_discriminant.rs | 42 -------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 src/test/ui/consts/const_discriminant.rs (limited to 'src/test/ui/consts/const_discriminant.rs') diff --git a/src/test/ui/consts/const_discriminant.rs b/src/test/ui/consts/const_discriminant.rs deleted file mode 100644 index 79e68590e..000000000 --- a/src/test/ui/consts/const_discriminant.rs +++ /dev/null @@ -1,42 +0,0 @@ -// run-pass -#![feature(const_discriminant)] -#![allow(dead_code)] - -use std::mem::{discriminant, Discriminant}; -use std::hint::black_box; - -enum Test { - A(u8), - B, - C { a: u8, b: u8 }, -} - -const TEST_A: Discriminant = discriminant(&Test::A(5)); -const TEST_A_OTHER: Discriminant = discriminant(&Test::A(17)); -const TEST_B: Discriminant = discriminant(&Test::B); - -enum Void {} - -enum SingleVariant { - V, - Never(Void), -} - -const TEST_V: Discriminant = discriminant(&SingleVariant::V); - -pub const TEST_VOID: () = { - // This is UB, but CTFE does not check validity so it does not detect this. - // This is a regression test for https://github.com/rust-lang/rust/issues/89765. - unsafe { std::mem::discriminant(&*(&() as *const () as *const Void)); }; -}; - - -fn main() { - assert_eq!(TEST_A, TEST_A_OTHER); - assert_eq!(TEST_A, discriminant(black_box(&Test::A(17)))); - assert_eq!(TEST_B, discriminant(black_box(&Test::B))); - assert_ne!(TEST_A, TEST_B); - assert_ne!(TEST_B, discriminant(black_box(&Test::C { a: 42, b: 7 }))); - - assert_eq!(TEST_V, discriminant(black_box(&SingleVariant::V))); -} -- cgit v1.2.3