rust/tests/ui/consts/const_unsafe_unreachable_ub.rs

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

15 lines
275 B
Rust
Raw Normal View History

2021-06-18 12:31:56 -05:00
// error-pattern: evaluation of constant value failed
const unsafe fn foo(x: bool) -> bool {
match x {
true => true,
false => std::hint::unreachable_unchecked(),
}
}
const BAR: bool = unsafe { foo(false) };
fn main() {
assert_eq!(BAR, true);
}