rust/tests/ui/consts/const_unsafe_unreachable_ub.rs
Ralf Jung 17946c22b1 const-eval error: always say in which item the error occurred
also adjust the wording a little so that we don't say "the error occurred here" for two different spans
2025-06-07 13:42:30 +02:00

17 lines
366 B
Rust

const unsafe fn foo(x: bool) -> bool {
match x {
true => true,
false => std::hint::unreachable_unchecked(),
//~^ NOTE inside `foo`
//~| NOTE the failure occurred here
}
}
const BAR: bool = unsafe { foo(false) };
//~^ NOTE failed inside this call
//~| ERROR entering unreachable code
fn main() {
assert_eq!(BAR, true);
}