]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/promoted_errors.rs
Fix some tests failing in `--pass check` mode
[rust.git] / src / test / ui / consts / const-eval / promoted_errors.rs
1 // revisions: noopt opt opt_with_overflow_checks
2 //[noopt]compile-flags: -C opt-level=0
3 //[opt]compile-flags: -O
4 //[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
5
6 // build-pass
7 // ignore-pass (test emits codegen-time warnings and verifies that they are not errors)
8
9 #![warn(const_err, arithmetic_overflow, unconditional_panic)]
10
11 fn main() {
12     println!("{}", 0u32 - 1);
13     //[opt_with_overflow_checks,noopt]~^ WARN [arithmetic_overflow]
14     let _x = 0u32 - 1;
15     //~^ WARN [arithmetic_overflow]
16     println!("{}", 1 / (1 - 1));
17     //~^ WARN [unconditional_panic]
18     //~| WARN panic or abort [const_err]
19     //~| WARN erroneous constant used [const_err]
20     let _x = 1 / (1 - 1);
21     //~^ WARN [unconditional_panic]
22     println!("{}", 1 / (false as u32));
23     //~^ WARN [unconditional_panic]
24     //~| WARN panic or abort [const_err]
25     //~| WARN erroneous constant used [const_err]
26     let _x = 1 / (false as u32);
27     //~^ WARN [unconditional_panic]
28 }