]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/lint-exceeding-bitshifts.rs
1f70828e411ef1cfc472b6ed1884690939457c71
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 #![feature(negate_unsigned)]
12 #![deny(exceeding_bitshifts)]
13 #![allow(unused_variables)]
15 #![feature(core, negate_unsigned)]
19 let n
= 1u8 << 8; //~ ERROR: bitshift exceeds the type's number of bits
21 let n
= 1u16 << 16; //~ ERROR: bitshift exceeds the type's number of bits
23 let n
= 1u32 << 32; //~ ERROR: bitshift exceeds the type's number of bits
25 let n
= 1u64 << 64; //~ ERROR: bitshift exceeds the type's number of bits
27 let n
= 1i8 << 8; //~ ERROR: bitshift exceeds the type's number of bits
29 let n
= 1i16 << 16; //~ ERROR: bitshift exceeds the type's number of bits
31 let n
= 1i32 << 32; //~ ERROR: bitshift exceeds the type's number of bits
33 let n
= 1i64 << 64; //~ ERROR: bitshift exceeds the type's number of bits
36 let n
= 1u8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits
38 let n
= 1u16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits
40 let n
= 1u32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits
42 let n
= 1u64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits
44 let n
= 1i8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits
46 let n
= 1i16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits
48 let n
= 1i32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits
50 let n
= 1i64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits
54 let n
= n
<< 8; //~ ERROR: bitshift exceeds the type's number of bits
56 let n
= 1u8 << -8; //~ ERROR: bitshift exceeds the type's number of bits
59 let n
= 1u8 << (4+4); //~ ERROR: bitshift exceeds the type's number of bits
61 let n
= 1_isize
<< std
::isize::BITS
; //~ ERROR: bitshift exceeds the type's number of bits
62 let n
= 1_usize
<< std
::usize::BITS
; //~ ERROR: bitshift exceeds the type's number of bits