rust/src/test/ui/lint/lint-exceeding-bitshifts2.rs

18 lines
629 B
Rust
Raw Normal View History

#![deny(exceeding_bitshifts, const_err)]
#![allow(unused_variables)]
2018-01-16 02:31:48 -06:00
#![allow(dead_code)]
fn main() {
let n = 1u8 << (4+3);
let n = 1u8 << (4+4); //~ ERROR: attempt to shift left with overflow
2018-01-16 02:31:48 -06:00
let n = 1i64 >> [63][0];
let n = 1i64 >> [64][0]; // should be linting, needs to wait for const propagation
#[cfg(target_pointer_width = "32")]
const BITS: usize = 32;
#[cfg(target_pointer_width = "64")]
const BITS: usize = 64;
let n = 1_isize << BITS; //~ ERROR: attempt to shift left with overflow
let n = 1_usize << BITS; //~ ERROR: attempt to shift left with overflow
2018-01-16 02:31:48 -06:00
}