diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/enum-discriminant/discriminant_value.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/enum-discriminant/discriminant_value.rs')
-rw-r--r-- | src/test/ui/enum-discriminant/discriminant_value.rs | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/test/ui/enum-discriminant/discriminant_value.rs b/src/test/ui/enum-discriminant/discriminant_value.rs deleted file mode 100644 index f3dfac298..000000000 --- a/src/test/ui/enum-discriminant/discriminant_value.rs +++ /dev/null @@ -1,82 +0,0 @@ -// run-pass -#![allow(stable_features)] -#![feature(core, core_intrinsics)] - -extern crate core; -use core::intrinsics::discriminant_value; - -enum CLike1 { - A, - B, - C, - D -} - -enum CLike2 { - A = 5, - B = 2, - C = 19, - D -} - -#[repr(i8)] -enum CLike3 { - A = 5, - B, - C = -1, - D -} - -#[allow(unused_tuple_struct_fields)] -enum ADT { - First(u32, u32), - Second(u64) -} - -enum NullablePointer { - Something(#[allow(unused_tuple_struct_fields)] &'static u32), - Nothing -} - -static CONST : u32 = 0xBEEF; - -#[allow(dead_code)] -#[repr(isize)] -enum Mixed { - Unit = 3, - Tuple(u16) = 2, - Struct { - a: u8, - b: u16, - } = 1, -} - -pub fn main() { - assert_eq!(discriminant_value(&CLike1::A), 0isize); - assert_eq!(discriminant_value(&CLike1::B), 1); - assert_eq!(discriminant_value(&CLike1::C), 2); - assert_eq!(discriminant_value(&CLike1::D), 3); - - assert_eq!(discriminant_value(&CLike2::A), 5isize); - assert_eq!(discriminant_value(&CLike2::B), 2); - assert_eq!(discriminant_value(&CLike2::C), 19); - assert_eq!(discriminant_value(&CLike2::D), 20); - - assert_eq!(discriminant_value(&CLike3::A), 5i8); - assert_eq!(discriminant_value(&CLike3::B), 6); - assert_eq!(discriminant_value(&CLike3::C), -1); - assert_eq!(discriminant_value(&CLike3::D), 0); - - assert_eq!(discriminant_value(&ADT::First(0,0)), 0isize); - assert_eq!(discriminant_value(&ADT::Second(5)), 1); - - assert_eq!(discriminant_value(&NullablePointer::Nothing), 1isize); - assert_eq!(discriminant_value(&NullablePointer::Something(&CONST)), 0); - - assert_eq!(discriminant_value(&10), 0u8); - assert_eq!(discriminant_value(&"test"), 0u8); - - assert_eq!(discriminant_value(&Mixed::Unit), 3isize); - assert_eq!(discriminant_value(&Mixed::Tuple(5)), 2); - assert_eq!(discriminant_value(&Mixed::Struct{a: 7, b: 11}), 1); -} |