]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/lint-exceeding-bitshifts2.rs
add test for issue 69020
[rust.git] / src / test / ui / lint / lint-exceeding-bitshifts2.rs
1 // build-fail
2 // compile-flags: -O
3
4 #![deny(exceeding_bitshifts, const_err)]
5 #![allow(unused_variables)]
6 #![allow(dead_code)]
7
8 fn main() {
9       let n = 1u8 << (4+3);
10       let n = 1u8 << (4+4); //~ ERROR: attempt to shift left with overflow
11       let n = 1i64 >> [63][0];
12       let n = 1i64 >> [64][0]; //~ ERROR: attempt to shift right with overflow
13
14       #[cfg(target_pointer_width = "32")]
15       const BITS: usize = 32;
16       #[cfg(target_pointer_width = "64")]
17       const BITS: usize = 64;
18       let n = 1_isize << BITS; //~ ERROR: attempt to shift left with overflow
19       let n = 1_usize << BITS; //~ ERROR: attempt to shift left with overflow
20 }