2018-10-29 00:09:32 -04:00
|
|
|
// issue-49296: Unsafe shenigans in constants can result in missing errors
|
|
|
|
|
|
2021-08-25 11:53:16 +00:00
|
|
|
use std::mem::transmute;
|
2018-10-29 00:09:32 -04:00
|
|
|
|
|
|
|
|
const fn wat(x: u64) -> &'static u64 {
|
|
|
|
|
unsafe { transmute(&x) }
|
|
|
|
|
}
|
2021-08-25 11:53:16 +00:00
|
|
|
|
2018-10-29 00:09:32 -04:00
|
|
|
const X: u64 = *wat(42);
|
2025-05-28 10:29:08 +00:00
|
|
|
//~^ ERROR dangling
|
2018-10-29 00:09:32 -04:00
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
println!("{}", X);
|
|
|
|
|
}
|