]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-err2.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / consts / const-err2.rs
1 // Copyright 2012 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 // needed because negating int::MIN will behave differently between
12 // optimized compilation and unoptimized compilation and thus would
13 // lead to different lints being emitted
14 // compile-flags: -O
15
16 #![feature(rustc_attrs)]
17 #![allow(exceeding_bitshifts)]
18 #![deny(const_err)]
19
20 fn black_box<T>(_: T) {
21     unimplemented!()
22 }
23
24 fn main() {
25     let a = -std::i8::MIN;
26     //~^ ERROR const_err
27     let b = 200u8 + 200u8 + 200u8;
28     //~^ ERROR const_err
29     let c = 200u8 * 4;
30     //~^ ERROR const_err
31     let d = 42u8 - (42u8 + 1);
32     //~^ ERROR const_err
33     let _e = [5u8][1];
34     //~^ ERROR const_err
35     black_box(a);
36     black_box(b);
37     black_box(c);
38     black_box(d);
39 }