2 // [thir]compile-flags: -Z thir-unsafeck
10 #[derive(Clone, Copy)]
12 topping: Option<PizzaTopping>
16 #[derive(Clone, Copy)]
22 fn do_nothing(_x: &mut Foo) {}
25 let mut foo = Foo { bar: 5 };
28 // This is UB, so this test isn't run
30 Foo { bar: _a } => {}, //~ ERROR access to union field is unsafe
32 match foo { //[mir]~ ERROR access to union field is unsafe
34 pizza: Pizza { //[thir]~ ERROR access to union field is unsafe
35 topping: Some(PizzaTopping::Cheese) | Some(PizzaTopping::Pineapple) | None
40 // MIR unsafeck incorrectly thinks that no unsafe block is needed to do these
42 Foo { zst: () } => {}, //[thir]~ ERROR access to union field is unsafe
45 Foo { pizza: Pizza { .. } } => {}, //[thir]~ ERROR access to union field is unsafe
48 // binding to wildcard is okay
52 let Foo { bar: _ } = foo;