]>
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)]
12 #![allow(unused_variables)]
14 #![feature(num_bits_bytes, const_indexing)]
18 let n
= 1u8 << 8; //~ ERROR: bitshift exceeds the type's number of bits
20 let n
= 1u16 << 16; //~ ERROR: bitshift exceeds the type's number of bits
22 let n
= 1u32 << 32; //~ ERROR: bitshift exceeds the type's number of bits
24 let n
= 1u64 << 64; //~ ERROR: bitshift exceeds the type's number of bits
26 let n
= 1i8 << 8; //~ ERROR: bitshift exceeds the type's number of bits
28 let n
= 1i16 << 16; //~ ERROR: bitshift exceeds the type's number of bits
30 let n
= 1i32 << 32; //~ ERROR: bitshift exceeds the type's number of bits
32 let n
= 1i64 << 64; //~ ERROR: bitshift exceeds the type's number of bits
35 let n
= 1u8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits
37 let n
= 1u16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits
39 let n
= 1u32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits
41 let n
= 1u64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits
43 let n
= 1i8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits
45 let n
= 1i16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits
47 let n
= 1i32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits
49 let n
= 1i64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits
53 let n
= n
<< 8; //~ ERROR: bitshift exceeds the type's number of bits
55 let n
= 1u8 << -8; //~ ERROR: bitshift exceeds the type's number of bits
58 let n
= 1u8 << (4+4); //~ ERROR: bitshift exceeds the type's number of bits
60 let n
= 1_isize
<< std
::isize::BITS
; //~ ERROR: bitshift exceeds the type's number of bits
61 let n
= 1_usize
<< std
::usize::BITS
; //~ ERROR: bitshift exceeds the type's number of bits
64 let n
= 1i8<<(1isize
+-1);
66 let n
= 1i64 >> [63][0];
67 let n
= 1i64 >> [64][0]; //~ ERROR: bitshift exceeds the type's number of bits