about summary refs log tree commit diff
path: root/tests/ui/unsafe/access_union_field.rs
blob: 4183119725eca707b7e57f63bb6df814499a205b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#![allow(unused_variables)]

union Foo {
    bar: i8,
    baz: u8,
}

fn main() {
    let foo = Foo { bar: 5 };
    let a = foo.bar; //~ ERROR access to union field is unsafe and requires unsafe function or block
    let b = foo.baz; //~ ERROR access to union field is unsafe and requires unsafe function or block
}