]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/const-negation.rs
Rollup merge of #106718 - lcnr:solver-cycles, r=compiler-errors
[rust.git] / tests / ui / consts / const-negation.rs
1 // run-pass
2 #![allow(overflowing_literals)]
3
4 fn main() {
5     #[cfg(target_pointer_width = "32")]
6     const I: isize = -2147483648isize;
7     #[cfg(target_pointer_width = "64")]
8     const I: isize = -9223372036854775808isize;
9     assert_eq!(i32::MIN as u64, 0xffffffff80000000);
10     assert_eq!(-2147483648isize as u64, 0xffffffff80000000);
11     assert_eq!(-2147483648i32 as u64, 0xffffffff80000000);
12     assert_eq!(i64::MIN as u64, 0x8000000000000000);
13     #[cfg(target_pointer_width = "64")]
14     assert_eq!(-9223372036854775808isize as u64, 0x8000000000000000);
15     #[cfg(target_pointer_width = "32")]
16     assert_eq!(-9223372036854775808isize as u64, 0);
17     assert_eq!(-9223372036854775808i32 as u64, 0);
18     const J: usize = i32::MAX as usize;
19     const K: usize = -1i32 as u32 as usize;
20     const L: usize = i32::MIN as usize;
21     const M: usize = i64::MIN as usize;
22     match 5 {
23         J => {},
24         K => {},
25         L => {},
26         M => {},
27         _ => {}
28     }
29     match 5 {
30         I => {},
31         _ => {}
32     }
33 }