2020-07-17 19:27:41 -05:00
|
|
|
// build-fail
|
|
|
|
|
2020-07-17 15:03:33 -05:00
|
|
|
#![feature(const_unreachable_unchecked)]
|
|
|
|
|
|
|
|
const unsafe fn foo(x: bool) -> bool {
|
|
|
|
match x {
|
|
|
|
true => true,
|
|
|
|
false => std::hint::unreachable_unchecked(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-17 19:27:41 -05:00
|
|
|
#[warn(const_err)]
|
2020-07-17 15:03:33 -05:00
|
|
|
const BAR: bool = unsafe { foo(false) };
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(BAR, true);
|
2020-07-17 19:27:41 -05:00
|
|
|
//~^ ERROR E0080
|
|
|
|
//~| ERROR erroneous constant
|
2021-01-30 07:49:22 -06:00
|
|
|
//~| WARN this was previously accepted by the compiler but is being phased out
|
2020-07-17 15:03:33 -05:00
|
|
|
}
|