mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +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() {}
|