]> git.proxmox.com Git - rustc.git/blame - src/test/ui/lint/lint-stability-fields.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / src / test / ui / lint / lint-stability-fields.rs
CommitLineData
c34b1796 1// aux-build:lint_stability_fields.rs
476ff2be 2#![allow(deprecated)]
c34b1796
AL
3#![allow(dead_code)]
4#![feature(staged_api)]
92a42be0
SL
5
6#![stable(feature = "rust1", since = "1.0.0")]
c34b1796
AL
7
8mod cross_crate {
9 extern crate lint_stability_fields;
10
94b46f34
XL
11 mod reexport {
12 #[stable(feature = "rust1", since = "1.0.0")]
13 pub use super::lint_stability_fields::*;
14 }
15
c34b1796
AL
16 use self::lint_stability_fields::*;
17
18 pub fn foo() {
19 let x = Stable {
20 inherit: 1,
21 override1: 2, //~ ERROR use of unstable
476ff2be 22 override2: 3, //~ ERROR use of unstable
6a06907d 23 override3: 4,
c34b1796
AL
24 };
25
26 let _ = x.inherit;
27 let _ = x.override1; //~ ERROR use of unstable
476ff2be 28 let _ = x.override2; //~ ERROR use of unstable
6a06907d 29 let _ = x.override3;
c34b1796
AL
30
31 let Stable {
32 inherit: _,
33 override1: _, //~ ERROR use of unstable
6a06907d
XL
34 override2: _, //~ ERROR use of unstable
35 override3: _
c34b1796
AL
36 } = x;
37 // all fine
38 let Stable { .. } = x;
39
6a06907d 40 let x = Stable2(1, 2, 3, 4);
c34b1796
AL
41
42 let _ = x.0;
43 let _ = x.1; //~ ERROR use of unstable
476ff2be 44 let _ = x.2; //~ ERROR use of unstable
6a06907d 45 let _ = x.3;
c34b1796
AL
46
47 let Stable2(_,
48 _, //~ ERROR use of unstable
6a06907d
XL
49 _, //~ ERROR use of unstable
50 _)
c34b1796
AL
51 = x;
52 // all fine
53 let Stable2(..) = x;
54
55
56 let x = Unstable { //~ ERROR use of unstable
57 inherit: 1, //~ ERROR use of unstable
58 override1: 2,
476ff2be 59 override2: 3, //~ ERROR use of unstable
c34b1796
AL
60 };
61
62 let _ = x.inherit; //~ ERROR use of unstable
63 let _ = x.override1;
476ff2be 64 let _ = x.override2; //~ ERROR use of unstable
c34b1796
AL
65
66 let Unstable { //~ ERROR use of unstable
67 inherit: _, //~ ERROR use of unstable
68 override1: _,
476ff2be 69 override2: _ //~ ERROR use of unstable
c34b1796
AL
70 } = x;
71
72 let Unstable //~ ERROR use of unstable
73 // the patterns are all fine:
74 { .. } = x;
75
94b46f34
XL
76 // Unstable items are still unstable even when used through a stable "pub use".
77 let x = reexport::Unstable2(1, 2, 3); //~ ERROR use of unstable
c34b1796
AL
78
79 let x = Unstable2(1, 2, 3); //~ ERROR use of unstable
80
81 let _ = x.0; //~ ERROR use of unstable
82 let _ = x.1;
476ff2be 83 let _ = x.2; //~ ERROR use of unstable
c34b1796
AL
84
85 let Unstable2 //~ ERROR use of unstable
86 (_, //~ ERROR use of unstable
87 _,
476ff2be 88 _) //~ ERROR use of unstable
c34b1796
AL
89 = x;
90 let Unstable2 //~ ERROR use of unstable
91 // the patterns are all fine:
92 (..) = x;
93
94
476ff2be
SL
95 let x = Deprecated { //~ ERROR use of unstable
96 inherit: 1, //~ ERROR use of unstable
c34b1796 97 override1: 2,
476ff2be 98 override2: 3, //~ ERROR use of unstable
c34b1796
AL
99 };
100
476ff2be 101 let _ = x.inherit; //~ ERROR use of unstable
c34b1796 102 let _ = x.override1;
476ff2be 103 let _ = x.override2; //~ ERROR use of unstable
c34b1796 104
476ff2be
SL
105 let Deprecated { //~ ERROR use of unstable
106 inherit: _, //~ ERROR use of unstable
c34b1796 107 override1: _,
476ff2be 108 override2: _ //~ ERROR use of unstable
c34b1796
AL
109 } = x;
110
476ff2be 111 let Deprecated //~ ERROR use of unstable
c34b1796
AL
112 // the patterns are all fine:
113 { .. } = x;
114
476ff2be 115 let x = Deprecated2(1, 2, 3); //~ ERROR use of unstable
c34b1796 116
476ff2be 117 let _ = x.0; //~ ERROR use of unstable
c34b1796 118 let _ = x.1;
476ff2be 119 let _ = x.2; //~ ERROR use of unstable
c34b1796 120
476ff2be
SL
121 let Deprecated2 //~ ERROR use of unstable
122 (_, //~ ERROR use of unstable
c34b1796 123 _,
476ff2be 124 _) //~ ERROR use of unstable
c34b1796 125 = x;
476ff2be 126 let Deprecated2 //~ ERROR use of unstable
c34b1796
AL
127 // the patterns are all fine:
128 (..) = x;
129 }
130}
131
132mod this_crate {
133 #[stable(feature = "rust1", since = "1.0.0")]
134 struct Stable {
135 inherit: u8,
dfeec247 136 #[unstable(feature = "unstable_test_feature", issue = "none")]
c34b1796 137 override1: u8,
5e7ed085 138 #[deprecated(since = "1.0.0", note = "text")]
dfeec247 139 #[unstable(feature = "unstable_test_feature", issue = "none")]
c34b1796 140 override2: u8,
6a06907d
XL
141 #[stable(feature = "rust2", since = "2.0.0")]
142 override3: u8,
c34b1796
AL
143 }
144
145 #[stable(feature = "rust1", since = "1.0.0")]
146 struct Stable2(u8,
6a06907d 147 #[stable(feature = "rust2", since = "2.0.0")] u8,
dfeec247 148 #[unstable(feature = "unstable_test_feature", issue = "none")]
5e7ed085 149 #[deprecated(since = "1.0.0", note = "text")] u8);
c34b1796 150
dfeec247 151 #[unstable(feature = "unstable_test_feature", issue = "none")]
c34b1796
AL
152 struct Unstable {
153 inherit: u8,
154 #[stable(feature = "rust1", since = "1.0.0")]
155 override1: u8,
5e7ed085 156 #[deprecated(since = "1.0.0", note = "text")]
dfeec247 157 #[unstable(feature = "unstable_test_feature", issue = "none")]
c34b1796
AL
158 override2: u8,
159 }
160
dfeec247 161 #[unstable(feature = "unstable_test_feature", issue = "none")]
c34b1796
AL
162 struct Unstable2(u8,
163 #[stable(feature = "rust1", since = "1.0.0")] u8,
dfeec247 164 #[unstable(feature = "unstable_test_feature", issue = "none")]
5e7ed085 165 #[deprecated(since = "1.0.0", note = "text")] u8);
c34b1796 166
dfeec247 167 #[unstable(feature = "unstable_test_feature", issue = "none")]
5e7ed085 168 #[deprecated(since = "1.0.0", note = "text")]
c34b1796
AL
169 struct Deprecated {
170 inherit: u8,
171 #[stable(feature = "rust1", since = "1.0.0")]
172 override1: u8,
dfeec247 173 #[unstable(feature = "unstable_test_feature", issue = "none")]
c34b1796
AL
174 override2: u8,
175 }
176
dfeec247 177 #[unstable(feature = "unstable_test_feature", issue = "none")]
5e7ed085 178 #[deprecated(since = "1.0.0", note = "text")]
c34b1796
AL
179 struct Deprecated2(u8,
180 #[stable(feature = "rust1", since = "1.0.0")] u8,
dfeec247 181 #[unstable(feature = "unstable_test_feature", issue = "none")] u8);
c34b1796
AL
182
183 pub fn foo() {
184 let x = Stable {
185 inherit: 1,
186 override1: 2,
187 override2: 3,
6a06907d 188 override3: 4,
c34b1796
AL
189 };
190
191 let _ = x.inherit;
192 let _ = x.override1;
193 let _ = x.override2;
6a06907d 194 let _ = x.override3;
c34b1796
AL
195
196 let Stable {
197 inherit: _,
198 override1: _,
6a06907d
XL
199 override2: _,
200 override3: _
c34b1796
AL
201 } = x;
202 // all fine
203 let Stable { .. } = x;
204
205 let x = Stable2(1, 2, 3);
206
207 let _ = x.0;
208 let _ = x.1;
209 let _ = x.2;
c34b1796
AL
210
211 let Stable2(_,
212 _,
213 _)
c34b1796
AL
214 = x;
215 // all fine
216 let Stable2(..) = x;
217
218
219 let x = Unstable {
220 inherit: 1,
221 override1: 2,
222 override2: 3,
c34b1796
AL
223 };
224
225 let _ = x.inherit;
226 let _ = x.override1;
227 let _ = x.override2;
c34b1796
AL
228
229 let Unstable {
230 inherit: _,
231 override1: _,
232 override2: _
c34b1796
AL
233 } = x;
234
235 let Unstable
236 // the patterns are all fine:
237 { .. } = x;
238
239
240 let x = Unstable2(1, 2, 3);
241
242 let _ = x.0;
243 let _ = x.1;
244 let _ = x.2;
c34b1796
AL
245
246 let Unstable2
247 (_,
248 _,
249 _)
c34b1796
AL
250 = x;
251 let Unstable2
252 // the patterns are all fine:
253 (..) = x;
254
255
256 let x = Deprecated {
c34b1796 257 inherit: 1,
c34b1796
AL
258 override1: 2,
259 override2: 3,
260 };
261
262 let _ = x.inherit;
c34b1796
AL
263 let _ = x.override1;
264 let _ = x.override2;
265
266 let Deprecated {
c34b1796 267 inherit: _,
c34b1796
AL
268 override1: _,
269 override2: _
270 } = x;
271
272 let Deprecated
c34b1796
AL
273 // the patterns are all fine:
274 { .. } = x;
275
276 let x = Deprecated2(1, 2, 3);
c34b1796
AL
277
278 let _ = x.0;
c34b1796
AL
279 let _ = x.1;
280 let _ = x.2;
281
282 let Deprecated2
c34b1796 283 (_,
c34b1796
AL
284 _,
285 _)
286 = x;
287 let Deprecated2
c34b1796
AL
288 // the patterns are all fine:
289 (..) = x;
290 }
291}
292
293fn main() {}