]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsafe/access_union_field.rs
Rollup merge of #106446 - bzEq:fix-unwind-lsda, r=Amanieu
[rust.git] / tests / ui / unsafe / access_union_field.rs
1 // revisions: mir thir
2 // [thir]compile-flags: -Z thir-unsafeck
3
4 #![allow(unused_variables)]
5
6 union Foo {
7     bar: i8,
8     baz: u8,
9 }
10
11 fn main() {
12     let foo = Foo { bar: 5 };
13     let a = foo.bar; //~ ERROR access to union field is unsafe and requires unsafe function or block
14     let b = foo.baz; //~ ERROR access to union field is unsafe and requires unsafe function or block
15 }