about summary refs log tree commit diff
path: root/src/test/ui/consts/const-err3.rs
blob: a9cf04cda7a5aed0be90fdfdd085e39b30b7d1f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// needed because negating int::MIN will behave differently between
// optimized compilation and unoptimized compilation and thus would
// lead to different lints being emitted
// compile-flags: -C overflow-checks=on -O

#![feature(rustc_attrs)]
#![allow(exceeding_bitshifts)]

#![deny(const_err)]

fn black_box<T>(_: T) {
    unimplemented!()
}

fn main() {
    let a = -std::i8::MIN;
    //~^ ERROR const_err
    let b = 200u8 + 200u8 + 200u8;
    //~^ ERROR const_err
    let c = 200u8 * 4;
    //~^ ERROR const_err
    let d = 42u8 - (42u8 + 1);
    //~^ ERROR const_err
    let _e = [5u8][1];
    //~^ ERROR const_err
    black_box(a);
    black_box(b);
    black_box(c);
    black_box(d);
}