rust/src/test/ui/consts/const-eval/conditional_array_execution.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
478 B
Rust
Raw Normal View History

// build-fail
#![warn(const_err)]
const X: u32 = 5;
const Y: u32 = 6;
const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
//~^ WARN any use of this value will cause an error
2021-01-30 13:49:22 +00:00
//~| WARN this was previously accepted by the compiler but is being phased out
fn main() {
println!("{}", FOO);
//~^ ERROR evaluation of constant value failed
//~| WARN erroneous constant used [const_err]
2021-01-30 13:49:22 +00:00
//~| WARN this was previously accepted by the compiler but is being phased out
}