]>
git.proxmox.com Git - rustc.git/blob - tests/ui/union/union-fields-2.rs
1 // revisions: mirunsafeck thirunsafeck
2 // [thirunsafeck]compile-flags: -Z thir-unsafeck
10 let u
= U {}
; //~ ERROR union expressions should have exactly one field
11 let u
= U { a: 0 }
; // OK
12 let u
= U { a: 0, b: 1 }
; //~ ERROR union expressions should have exactly one field
13 let u
= U { a: 0, b: 1, c: 2 }
; //~ ERROR union expressions should have exactly one field
14 //~^ ERROR union `U` has no field named `c`
15 let u
= U { ..u }
; //~ ERROR union expressions should have exactly one field
16 //~^ ERROR functional record update syntax requires a struct
18 let U {}
= u
; //~ ERROR union patterns should have exactly one field
19 let U { a }
= u
; // OK
20 let U { a, b }
= u
; //~ ERROR union patterns should have exactly one field
21 let U { a, b, c }
= u
; //~ ERROR union patterns should have exactly one field
22 //~^ ERROR union `U` does not have a field named `c`
23 let U { .. }
= u
; //~ ERROR union patterns should have exactly one field
24 //~^ ERROR `..` cannot be used in union patterns
25 let U { a, .. }
= u
; //~ ERROR `..` cannot be used in union patterns