gcc/testsuite/rust/compile/match8.rs
raw| 1 | union MyUnion { |
| 2 | f1: u32, |
| 3 | f2: f32, |
| 4 | } |
| 5 | |
| 6 | fn f(u: MyUnion) -> i32 { |
| 7 | unsafe { |
| 8 | match u { |
| 9 | MyUnion { f1: 10 } => 0, |
| 10 | MyUnion { f2 } => 0, |
| 11 | MyUnion { f1: 10, f2: 10.0 } => 0, // { dg-error "union patterns should have exactly one field" "" } |
| 12 | MyUnion {} => 0, // { dg-error "union patterns should have exactly one field" "" } |
| 13 | MyUnion { f1: () } => 0, // { dg-error "expected u32, found tuple" "" } |
| 14 | _ => 1, |
| 15 | } |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | fn main() {} |