1
Fork 0
rust/src/test/ui/consts/const-err2.rs

39 lines
870 B
Rust
Raw Normal View History

// needed because negating int::MIN will behave differently between
// optimized compilation and unoptimized compilation and thus would
// lead to different lints being emitted
// build-fail
// compile-flags: -O
#![feature(rustc_attrs)]
#![allow(exceeding_bitshifts)]
2019-09-02 03:40:35 +09:00
#![deny(const_err)]
fn black_box<T>(_: T) {
unimplemented!()
}
fn main() {
let a = -std::i8::MIN;
2019-09-02 03:06:11 +09:00
//~^ ERROR const_err
let a_i128 = -std::i128::MIN;
//~^ ERROR const_err
let b = 200u8 + 200u8 + 200u8;
2019-09-02 03:06:11 +09:00
//~^ ERROR const_err
let b_i128 = std::i128::MIN - std::i128::MAX;
//~^ ERROR const_err
let c = 200u8 * 4;
2019-09-02 03:06:11 +09:00
//~^ ERROR const_err
let d = 42u8 - (42u8 + 1);
2019-09-02 03:06:11 +09:00
//~^ ERROR const_err
let _e = [5u8][1];
//~^ ERROR const_err
black_box(a);
black_box(a_i128);
black_box(b);
black_box(b_i128);
black_box(c);
black_box(d);
}