mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
77fe9f0a72
validation produces much higher quality errors and already handles most of the cases
30 lines
663 B
Rust
30 lines
663 B
Rust
const FOO: *const u32 = {
|
|
//~^ ERROR encountered dangling pointer in final value of constant
|
|
let x = 42;
|
|
&x
|
|
};
|
|
|
|
union Union {
|
|
ptr: *const u32,
|
|
}
|
|
|
|
const BAR: Union = {
|
|
//~^ ERROR encountered dangling pointer in final value of constant
|
|
let x = 42;
|
|
Union { ptr: &x }
|
|
};
|
|
|
|
const BAZ: Union = {
|
|
//~^ ERROR encountered dangling pointer in final value of constant
|
|
let x = 42_u32;
|
|
Union { ptr: &(&x as *const u32) as *const *const u32 as _ }
|
|
};
|
|
|
|
const FOOMP: *const u32 = {
|
|
//~^ ERROR encountered dangling pointer in final value of constant
|
|
let x = 42_u32;
|
|
&(&x as *const u32) as *const *const u32 as _
|
|
};
|
|
|
|
fn main() {}
|