|
10 | 10 |
|
11 | 11 | #![deny(exceeding_bitshifts)]
|
12 | 12 | #![allow(unused_variables)]
|
| 13 | +#![allow(dead_code)] |
13 | 14 |
|
14 | 15 | fn main() {
|
15 |
| - let n = 1u8 << 8; |
16 |
| - let n = 1u8 << 9; //~ ERROR: bitshift exceeds the type's number of bits |
17 |
| - let n = 1u16 << 16; |
18 |
| - let n = 1u16 << 17; //~ ERROR: bitshift exceeds the type's number of bits |
19 |
| - let n = 1u32 << 32; |
20 |
| - let n = 1u32 << 33; //~ ERROR: bitshift exceeds the type's number of bits |
21 |
| - let n = 1u64 << 64; |
22 |
| - let n = 1u64 << 65; //~ ERROR: bitshift exceeds the type's number of bits |
23 |
| - let n = 1i8 << 8; |
24 |
| - let n = 1i8 << 9; //~ ERROR: bitshift exceeds the type's number of bits |
25 |
| - let n = 1i16 << 16; |
26 |
| - let n = 1i16 << 17; //~ ERROR: bitshift exceeds the type's number of bits |
27 |
| - let n = 1i32 << 32; |
28 |
| - let n = 1i32 << 33; //~ ERROR: bitshift exceeds the type's number of bits |
29 |
| - let n = 1i64 << 64; |
30 |
| - let n = 1i64 << 65; //~ ERROR: bitshift exceeds the type's number of bits |
31 |
| - |
32 |
| - let n = 1u8 >> 8; |
33 |
| - let n = 1u8 >> 9; //~ ERROR: bitshift exceeds the type's number of bits |
34 |
| - let n = 1u16 >> 16; |
35 |
| - let n = 1u16 >> 17; //~ ERROR: bitshift exceeds the type's number of bits |
36 |
| - let n = 1u32 >> 32; |
37 |
| - let n = 1u32 >> 33; //~ ERROR: bitshift exceeds the type's number of bits |
38 |
| - let n = 1u64 >> 64; |
39 |
| - let n = 1u64 >> 65; //~ ERROR: bitshift exceeds the type's number of bits |
40 |
| - let n = 1i8 >> 8; |
41 |
| - let n = 1i8 >> 9; //~ ERROR: bitshift exceeds the type's number of bits |
42 |
| - let n = 1i16 >> 16; |
43 |
| - let n = 1i16 >> 17; //~ ERROR: bitshift exceeds the type's number of bits |
44 |
| - let n = 1i32 >> 32; |
45 |
| - let n = 1i32 >> 33; //~ ERROR: bitshift exceeds the type's number of bits |
46 |
| - let n = 1i64 >> 64; |
47 |
| - let n = 1i64 >> 65; //~ ERROR: bitshift exceeds the type's number of bits |
| 16 | + let n = 1u8 << 7; |
| 17 | + let n = 1u8 << 8; //~ ERROR: bitshift exceeds the type's number of bits |
| 18 | + let n = 1u16 << 15; |
| 19 | + let n = 1u16 << 16; //~ ERROR: bitshift exceeds the type's number of bits |
| 20 | + let n = 1u32 << 31; |
| 21 | + let n = 1u32 << 32; //~ ERROR: bitshift exceeds the type's number of bits |
| 22 | + let n = 1u64 << 63; |
| 23 | + let n = 1u64 << 64; //~ ERROR: bitshift exceeds the type's number of bits |
| 24 | + let n = 1i8 << 7; |
| 25 | + let n = 1i8 << 8; //~ ERROR: bitshift exceeds the type's number of bits |
| 26 | + let n = 1i16 << 15; |
| 27 | + let n = 1i16 << 16; //~ ERROR: bitshift exceeds the type's number of bits |
| 28 | + let n = 1i32 << 31; |
| 29 | + let n = 1i32 << 32; //~ ERROR: bitshift exceeds the type's number of bits |
| 30 | + let n = 1i64 << 63; |
| 31 | + let n = 1i64 << 64; //~ ERROR: bitshift exceeds the type's number of bits |
| 32 | + |
| 33 | + let n = 1u8 >> 7; |
| 34 | + let n = 1u8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits |
| 35 | + let n = 1u16 >> 15; |
| 36 | + let n = 1u16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits |
| 37 | + let n = 1u32 >> 31; |
| 38 | + let n = 1u32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits |
| 39 | + let n = 1u64 >> 63; |
| 40 | + let n = 1u64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits |
| 41 | + let n = 1i8 >> 7; |
| 42 | + let n = 1i8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits |
| 43 | + let n = 1i16 >> 15; |
| 44 | + let n = 1i16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits |
| 45 | + let n = 1i32 >> 31; |
| 46 | + let n = 1i32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits |
| 47 | + let n = 1i64 >> 63; |
| 48 | + let n = 1i64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits |
48 | 49 |
|
49 | 50 | let n = 1u8;
|
50 |
| - let n = n << 8; |
51 |
| - let n = n << 9; //~ ERROR: bitshift exceeds the type's number of bits |
| 51 | + let n = n << 7; |
| 52 | + let n = n << 8; //~ ERROR: bitshift exceeds the type's number of bits |
| 53 | + |
| 54 | + let n = 1u8 << -8; //~ ERROR: bitshift exceeds the type's number of bits |
| 55 | + |
| 56 | + let n = 1u8 << (4+3); |
| 57 | + let n = 1u8 << (4+4); //~ ERROR: bitshift exceeds the type's number of bits |
52 | 58 |
|
53 |
| - let n = 1u8 << -9; //~ ERROR: bitshift exceeds the type's number of bits |
| 59 | + #[cfg(target_word_size = "32")] |
| 60 | + fn dead_but_still_linted() { |
| 61 | + let n = 1i << 32; //~ ERROR: bitshift exceeds the type's number of bits |
| 62 | + let n = 1u << 32; //~ ERROR: bitshift exceeds the type's number of bits |
| 63 | + } |
54 | 64 |
|
55 |
| - let n = 1u8 << (4+4); |
56 |
| - let n = 1u8 << (4+5); //~ ERROR: bitshift exceeds the type's number of bits |
| 65 | + #[cfg(target_word_size = "64")] |
| 66 | + fn dead_but_still_still_linted() { |
| 67 | + let n = 1i << 64; //~ ERROR: bitshift exceeds the type's number of bits |
| 68 | + let n = 1u << 64; //~ ERROR: bitshift exceeds the type's number of bits |
| 69 | + } |
57 | 70 | }
|
58 | 71 |
|
0 commit comments