]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-err2.rs
Rollup merge of #69051 - Centril:st-fixes, r=eddyb
[rust.git] / src / test / ui / consts / const-err2.rs
1 // needed because negating int::MIN will behave differently between
2 // optimized compilation and unoptimized compilation and thus would
3 // lead to different lints being emitted
4
5 // build-fail
6 // compile-flags: -O
7
8 #![feature(rustc_attrs)]
9 #![allow(exceeding_bitshifts)]
10
11 #![deny(const_err)]
12
13 fn black_box<T>(_: T) {
14     unimplemented!()
15 }
16
17 fn main() {
18     let a = -std::i8::MIN;
19     //~^ ERROR const_err
20     let a_i128 = -std::i128::MIN;
21     //~^ ERROR const_err
22     let b = 200u8 + 200u8 + 200u8;
23     //~^ ERROR const_err
24     let b_i128 = std::i128::MIN - std::i128::MAX;
25     //~^ ERROR const_err
26     let c = 200u8 * 4;
27     //~^ ERROR const_err
28     let d = 42u8 - (42u8 + 1);
29     //~^ ERROR const_err
30     let _e = [5u8][1];
31     //~^ ERROR const_err
32     black_box(a);
33     black_box(a_i128);
34     black_box(b);
35     black_box(b_i128);
36     black_box(c);
37     black_box(d);
38 }