Files
rust/src/test/ui/consts/const-eval/promoted_errors.rs

29 lines
997 B
Rust
Raw Normal View History

// revisions: default noopt opt opt_with_overflow_checks
//[noopt]compile-flags: -C opt-level=0
//[opt]compile-flags: -O
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
// build-pass
// ignore-pass (emit codegen-time warnings and verify that they are indeed warnings and not errors)
2019-06-12 22:53:00 +02:00
2020-02-18 22:49:47 +01:00
#![warn(const_err, arithmetic_overflow, unconditional_panic)]
2019-06-12 22:53:00 +02:00
fn main() {
println!("{}", 0u32 - 1);
2020-02-18 22:49:47 +01:00
//[opt_with_overflow_checks,noopt]~^ WARN [arithmetic_overflow]
let _x = 0u32 - 1;
2020-02-18 22:49:47 +01:00
//~^ WARN [arithmetic_overflow]
println!("{}", 1 / (1 - 1));
2020-02-18 22:49:47 +01:00
//~^ WARN [unconditional_panic]
//~| WARN panic or abort [const_err]
//~| WARN erroneous constant used [const_err]
let _x = 1 / (1 - 1);
2020-02-18 22:49:47 +01:00
//~^ WARN [unconditional_panic]
println!("{}", 1 / (false as u32));
2020-02-18 22:49:47 +01:00
//~^ WARN [unconditional_panic]
//~| WARN panic or abort [const_err]
//~| WARN erroneous constant used [const_err]
let _x = 1 / (false as u32);
2020-02-18 22:49:47 +01:00
//~^ WARN [unconditional_panic]
}