Files
rust/tests/ui/consts/const-eval/ub-invalid-values.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

13 lines
341 B
Rust

const fn bool_cast(ptr: *const bool) { unsafe {
let _val = *ptr as u32; //~ NOTE inside `bool_cast`
//~^ NOTE the failure occurred here
}}
const _: () = {
let v = 3_u8;
bool_cast(&v as *const u8 as *const bool); //~ NOTE: failed inside this call
//~^ ERROR interpreting an invalid 8-bit value as a bool
};
fn main() {}