]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/empty-struct-braces.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / run-pass / empty-struct-braces.rs
CommitLineData
b039eaaf
SL
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
9cc50fc6
SL
14// aux-build:empty-struct.rs
15
9cc50fc6
SL
16extern crate empty_struct;
17use empty_struct::*;
18
b039eaaf
SL
19struct Empty1 {}
20struct Empty2;
54a0048b
SL
21
22#[derive(PartialEq, Eq)]
b039eaaf 23struct Empty3 {}
54a0048b 24
b039eaaf
SL
25const Empty3: Empty3 = Empty3 {};
26
27enum E {
28 Empty4 {},
29 Empty5,
30}
31
9cc50fc6 32fn local() {
b039eaaf
SL
33 let e1: Empty1 = Empty1 {};
34 let e2: Empty2 = Empty2 {};
35 let e2: Empty2 = Empty2;
36 let e3: Empty3 = Empty3 {};
37 let e3: Empty3 = Empty3;
38 let e4: E = E::Empty4 {};
92a42be0 39 let e5: E = E::Empty5 {};
b039eaaf
SL
40 let e5: E = E::Empty5;
41
42 match e1 {
43 Empty1 {} => {}
44 }
45 match e2 {
46 Empty2 {} => {}
47 }
48 match e3 {
49 Empty3 {} => {}
50 }
51 match e4 {
52 E::Empty4 {} => {}
53 _ => {}
54 }
92a42be0
SL
55 match e5 {
56 E::Empty5 {} => {}
57 _ => {}
58 }
b039eaaf
SL
59
60 match e1 {
61 Empty1 { .. } => {}
62 }
63 match e2 {
64 Empty2 { .. } => {}
65 }
66 match e3 {
67 Empty3 { .. } => {}
68 }
69 match e4 {
70 E::Empty4 { .. } => {}
71 _ => {}
72 }
92a42be0
SL
73 match e5 {
74 E::Empty5 { .. } => {}
75 _ => {}
76 }
b039eaaf
SL
77
78 match e2 {
79 Empty2 => {}
80 }
81 match e3 {
82 Empty3 => {}
83 }
84 match e5 {
85 E::Empty5 => {}
86 _ => {}
87 }
88
89 let e11: Empty1 = Empty1 { ..e1 };
90 let e22: Empty2 = Empty2 { ..e2 };
91 let e33: Empty3 = Empty3 { ..e3 };
92}
9cc50fc6
SL
93
94fn xcrate() {
95 let e1: XEmpty1 = XEmpty1 {};
96 let e2: XEmpty2 = XEmpty2 {};
97 let e2: XEmpty2 = XEmpty2;
98 let e3: XE = XE::XEmpty3 {};
7453a54e 99 let e4: XE = XE::XEmpty4 {};
9cc50fc6
SL
100 let e4: XE = XE::XEmpty4;
101
102 match e1 {
103 XEmpty1 {} => {}
104 }
105 match e2 {
106 XEmpty2 {} => {}
107 }
108 match e3 {
109 XE::XEmpty3 {} => {}
110 _ => {}
111 }
7453a54e
SL
112 match e4 {
113 XE::XEmpty4 {} => {}
114 _ => {}
115 }
9cc50fc6
SL
116
117 match e1 {
118 XEmpty1 { .. } => {}
119 }
120 match e2 {
121 XEmpty2 { .. } => {}
122 }
123 match e3 {
124 XE::XEmpty3 { .. } => {}
125 _ => {}
126 }
7453a54e
SL
127 match e4 {
128 XE::XEmpty4 { .. } => {}
129 _ => {}
130 }
9cc50fc6
SL
131
132 match e2 {
133 XEmpty2 => {}
134 }
7453a54e
SL
135 match e4 {
136 XE::XEmpty4 => {}
137 _ => {}
138 }
9cc50fc6
SL
139
140 let e11: XEmpty1 = XEmpty1 { ..e1 };
141 let e22: XEmpty2 = XEmpty2 { ..e2 };
142}
143
144fn main() {
145 local();
146 xcrate();
147}