]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/lint-exceeding-bitshifts2.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / lint / lint-exceeding-bitshifts2.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.
4 //
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.
10
11 #![deny(exceeding_bitshifts, const_err)]
12 #![allow(unused_variables)]
13 #![allow(dead_code)]
14
15 fn main() {
16       let n = 1u8 << (4+3);
17       let n = 1u8 << (4+4); //~ ERROR: attempt to shift left with overflow
18       let n = 1i64 >> [63][0];
19       let n = 1i64 >> [64][0]; // should be linting, needs to wait for const propagation
20
21       #[cfg(target_pointer_width = "32")]
22       const BITS: usize = 32;
23       #[cfg(target_pointer_width = "64")]
24       const BITS: usize = 64;
25       let n = 1_isize << BITS; //~ ERROR: attempt to shift left with overflow
26       let n = 1_usize << BITS; //~ ERROR: attempt to shift left with overflow
27 }