]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const-eval/promoted_errors.rs
3ab6ce28478c39ae0d72ff356c1d89fbb5d37ae1
[rustc.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 (emit codegen-time warnings and verify that they are indeed warnings and 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 }