]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/empty-struct-braces.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / run-pass / empty-struct-braces.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Empty struct defined with braces add names into type namespace
12 // Empty struct defined without braces add names into both type and value namespaces
13
14 #![feature(braced_empty_structs)]
15
16 struct Empty1 {}
17 struct Empty2;
18 struct Empty3 {}
19 const Empty3: Empty3 = Empty3 {};
20
21 enum E {
22     Empty4 {},
23     Empty5,
24 }
25
26 fn main() {
27     let e1: Empty1 = Empty1 {};
28     let e2: Empty2 = Empty2 {};
29     let e2: Empty2 = Empty2;
30     let e3: Empty3 = Empty3 {};
31     let e3: Empty3 = Empty3;
32     let e4: E = E::Empty4 {};
33     // let e5: E = E::Empty5 {}; // Issue #28692
34     let e5: E = E::Empty5;
35
36     match e1 {
37         Empty1 {} => {}
38     }
39     match e2 {
40         Empty2 {} => {}
41     }
42     match e3 {
43         Empty3 {} => {}
44     }
45     match e4 {
46         E::Empty4 {} => {}
47         _ => {}
48     }
49     // Issue #28692
50     // match e5 {
51     //     E::Empty5 {} => {}
52     //     _ => {}
53     // }
54
55     match e1 {
56         Empty1 { .. } => {}
57     }
58     match e2 {
59         Empty2 { .. } => {}
60     }
61     match e3 {
62         Empty3 { .. } => {}
63     }
64     match e4 {
65         E::Empty4 { .. } => {}
66         _ => {}
67     }
68     // Issue #28692
69     // match e5 {
70     //     E::Empty5 { .. } => {}
71     //     _ => {}
72     // }
73
74     match e2 {
75         Empty2 => {}
76     }
77     match e3 {
78         Empty3 => {}
79     }
80     match e5 {
81         E::Empty5 => {}
82         _ => {}
83     }
84
85     let e11: Empty1 = Empty1 { ..e1 };
86     let e22: Empty2 = Empty2 { ..e2 };
87     let e33: Empty3 = Empty3 { ..e3 };
88 }