2019-12-13 21:28:32 -06:00
|
|
|
// build-fail
|
|
|
|
|
2018-05-11 07:33:37 -05:00
|
|
|
#![warn(const_err)]
|
2018-04-08 15:26:28 -05:00
|
|
|
|
2017-07-31 09:42:42 -05:00
|
|
|
const fn foo(x: u32) -> u32 {
|
|
|
|
x
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2018-03-06 05:43:02 -06:00
|
|
|
const X: u32 = 0-1;
|
2018-08-26 08:19:34 -05:00
|
|
|
//~^ WARN any use of this value will cause
|
2018-03-06 05:43:02 -06:00
|
|
|
const Y: u32 = foo(0-1);
|
2018-08-26 08:19:34 -05:00
|
|
|
//~^ WARN any use of this value will cause
|
2017-07-31 09:42:42 -05:00
|
|
|
println!("{} {}", X, Y);
|
2018-08-26 08:19:34 -05:00
|
|
|
//~^ ERROR evaluation of constant expression failed
|
|
|
|
//~| ERROR evaluation of constant expression failed
|
2019-11-22 14:26:09 -06:00
|
|
|
//~| ERROR erroneous constant used [E0080]
|
|
|
|
//~| ERROR erroneous constant used [E0080]
|
2017-07-31 09:42:42 -05:00
|
|
|
}
|