mirror of
https://git.proxmox.com/git/rustc
synced 2025-08-15 05:04:23 +00:00
20 lines
300 B
Rust
20 lines
300 B
Rust
union U {
|
|
a: &'static i32,
|
|
b: usize,
|
|
}
|
|
|
|
fn fun(U { a }: U) {
|
|
//~^ ERROR access to union field is unsafe
|
|
dbg!(*a);
|
|
}
|
|
|
|
fn main() {
|
|
fun(U { b: 0 });
|
|
|
|
let closure = |U { a }| {
|
|
//~^ ERROR access to union field is unsafe
|
|
dbg!(*a);
|
|
};
|
|
closure(U { b: 0 });
|
|
}
|