]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/lint-exceeding-bitshifts.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![deny(exceeding_bitshifts, const_err)]
12 #![allow(unused_variables)]
17 let n
= 1u8 << 8; //~ ERROR: attempt to shift left with overflow
19 let n
= 1u16 << 16; //~ ERROR: attempt to shift left with overflow
21 let n
= 1u32 << 32; //~ ERROR: attempt to shift left with overflow
23 let n
= 1u64 << 64; //~ ERROR: attempt to shift left with overflow
25 let n
= 1i8 << 8; //~ ERROR: attempt to shift left with overflow
27 let n
= 1i16 << 16; //~ ERROR: attempt to shift left with overflow
29 let n
= 1i32 << 32; //~ ERROR: attempt to shift left with overflow
31 let n
= 1i64 << 64; //~ ERROR: attempt to shift left with overflow
34 let n
= 1u8 >> 8; //~ ERROR: attempt to shift right with overflow
36 let n
= 1u16 >> 16; //~ ERROR: attempt to shift right with overflow
38 let n
= 1u32 >> 32; //~ ERROR: attempt to shift right with overflow
40 let n
= 1u64 >> 64; //~ ERROR: attempt to shift right with overflow
42 let n
= 1i8 >> 8; //~ ERROR: attempt to shift right with overflow
44 let n
= 1i16 >> 16; //~ ERROR: attempt to shift right with overflow
46 let n
= 1i32 >> 32; //~ ERROR: attempt to shift right with overflow
48 let n
= 1i64 >> 64; //~ ERROR: attempt to shift right with overflow
52 let n
= n
<< 8; //~ ERROR: attempt to shift left with overflow
54 let n
= 1u8 << -8; //~ ERROR: attempt to shift left with overflow
56 let n
= 1i8<<(1isize
+-1);