1 // aux-build:structs.rs
4 use structs::{NormalStruct, UnitStruct, TupleStruct, FunctionalRecord};
7 let fr = FunctionalRecord {
8 //~^ ERROR cannot create non-exhaustive struct
11 ..FunctionalRecord::default()
14 let ns = NormalStruct { first_field: 640, second_field: 480 };
15 //~^ ERROR cannot create non-exhaustive struct
17 let NormalStruct { first_field, second_field } = ns;
18 //~^ ERROR `..` required with struct marked as non-exhaustive
20 let ts = TupleStruct(640, 480);
21 //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423]
23 let ts_explicit = structs::TupleStruct(640, 480);
24 //~^ ERROR tuple struct constructor `TupleStruct` is private [E0603]
26 let TupleStruct { 0: first_field, 1: second_field } = ts;
27 //~^ ERROR `..` required with struct marked as non-exhaustive
30 //~^ ERROR expected value, found struct `UnitStruct` [E0423]
32 let us_explicit = structs::UnitStruct;
33 //~^ ERROR unit struct `UnitStruct` is private [E0603]
35 let UnitStruct { } = us;
36 //~^ ERROR `..` required with struct marked as non-exhaustive
39 // Everything below this is expected to compile successfully.
41 // We only test matching here as we cannot create non-exhaustive
42 // structs from another crate. ie. they'll never pass in run-pass tests.
43 fn match_structs(ns: NormalStruct, ts: TupleStruct, us: UnitStruct) {
44 let NormalStruct { first_field, second_field, .. } = ns;
46 let TupleStruct { 0: first, 1: second, .. } = ts;
48 let UnitStruct { .. } = us;