about summary refs log tree commit diff
path: root/tests/ui/unsafe/union-pat-in-param.rs
blob: 8454bfb20dcb85673e674a0ba9d2da40bc7a4cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 });
}