2 // Test a ZST enum whose dicriminant is ~0i128. This caused an ICE when casting to an i32.
3 use std::hint::black_box;
10 const NEG_ONE_I8: i8 = Nums::NegOne as i8;
11 const NEG_ONE_I16: i16 = Nums::NegOne as i16;
12 const NEG_ONE_I32: i32 = Nums::NegOne as i32;
13 const NEG_ONE_I64: i64 = Nums::NegOne as i64;
14 const NEG_ONE_I128: i128 = Nums::NegOne as i128;
16 fn test_as_arg(n: Nums) {
17 assert_eq!(-1i8, n as i8);
18 assert_eq!(-1i16, n as i16);
19 assert_eq!(-1i32, n as i32);
20 assert_eq!(-1i64, n as i64);
21 assert_eq!(-1i128, n as i128);
25 let kind = Nums::NegOne;
26 assert_eq!(-1i8, kind as i8);
27 assert_eq!(-1i16, kind as i16);
28 assert_eq!(-1i32, kind as i32);
29 assert_eq!(-1i64, kind as i64);
30 assert_eq!(-1i128, kind as i128);
32 assert_eq!(-1i8, black_box(kind) as i8);
33 assert_eq!(-1i16, black_box(kind) as i16);
34 assert_eq!(-1i32, black_box(kind) as i32);
35 assert_eq!(-1i64, black_box(kind) as i64);
36 assert_eq!(-1i128, black_box(kind) as i128);
38 test_as_arg(Nums::NegOne);
40 assert_eq!(-1i8, NEG_ONE_I8);
41 assert_eq!(-1i16, NEG_ONE_I16);
42 assert_eq!(-1i32, NEG_ONE_I32);
43 assert_eq!(-1i64, NEG_ONE_I64);
44 assert_eq!(-1i128, NEG_ONE_I128);