rust/tests/ui/unsafe/union-pat-in-param.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
300 B
Rust
Raw Normal View History

2024-09-18 15:45:27 -05:00
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 });
}