]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/lint-stability-fields.rs
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / test / compile-fail / lint-stability-fields.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 // aux-build:lint_stability_fields.rs
12 #![deny(deprecated)]
13 #![allow(dead_code)]
14 #![feature(staged_api)]
15
16 #![stable(feature = "rust1", since = "1.0.0")]
17
18 mod cross_crate {
19 extern crate lint_stability_fields;
20
21 use self::lint_stability_fields::*;
22
23 pub fn foo() {
24 let x = Stable {
25 inherit: 1,
26 override1: 2, //~ ERROR use of unstable
27 override2: 3,
28 //~^ ERROR use of deprecated item
29 //~^^ ERROR use of unstable
30 };
31
32 let _ = x.inherit;
33 let _ = x.override1; //~ ERROR use of unstable
34 let _ = x.override2;
35 //~^ ERROR use of deprecated item
36 //~^^ ERROR use of unstable
37
38 let Stable {
39 inherit: _,
40 override1: _, //~ ERROR use of unstable
41 override2: _
42 //~^ ERROR use of deprecated item
43 //~^^ ERROR use of unstable
44 } = x;
45 // all fine
46 let Stable { .. } = x;
47
48 let x = Stable2(1, 2, 3);
49
50 let _ = x.0;
51 let _ = x.1; //~ ERROR use of unstable
52 let _ = x.2;
53 //~^ ERROR use of deprecated item
54 //~^^ ERROR use of unstable
55
56 let Stable2(_,
57 _, //~ ERROR use of unstable
58 _)
59 //~^ ERROR use of deprecated item
60 //~^^ ERROR use of unstable
61 = x;
62 // all fine
63 let Stable2(..) = x;
64
65
66 let x = Unstable { //~ ERROR use of unstable
67 inherit: 1, //~ ERROR use of unstable
68 override1: 2,
69 override2: 3,
70 //~^ ERROR use of deprecated item
71 //~^^ ERROR use of unstable
72 };
73
74 let _ = x.inherit; //~ ERROR use of unstable
75 let _ = x.override1;
76 let _ = x.override2;
77 //~^ ERROR use of deprecated item
78 //~^^ ERROR use of unstable
79
80 let Unstable { //~ ERROR use of unstable
81 inherit: _, //~ ERROR use of unstable
82 override1: _,
83 override2: _
84 //~^ ERROR use of deprecated item
85 //~^^ ERROR use of unstable
86 } = x;
87
88 let Unstable //~ ERROR use of unstable
89 // the patterns are all fine:
90 { .. } = x;
91
92
93 let x = Unstable2(1, 2, 3); //~ ERROR use of unstable
94
95 let _ = x.0; //~ ERROR use of unstable
96 let _ = x.1;
97 let _ = x.2;
98 //~^ ERROR use of deprecated item
99 //~^^ ERROR use of unstable
100
101 let Unstable2 //~ ERROR use of unstable
102 (_, //~ ERROR use of unstable
103 _,
104 _)
105 //~^ ERROR use of deprecated item
106 //~^^ ERROR use of unstable
107 = x;
108 let Unstable2 //~ ERROR use of unstable
109 // the patterns are all fine:
110 (..) = x;
111
112
113 let x = Deprecated {
114 //~^ ERROR use of deprecated item
115 //~^^ ERROR use of unstable
116 inherit: 1,
117 //~^ ERROR use of deprecated item
118 //~^^ ERROR use of unstable
119 override1: 2,
120 //~^ ERROR use of deprecated item
121 override2: 3,
122 //~^ ERROR use of deprecated item
123 //~^^ ERROR use of unstable
124 };
125
126 let _ = x.inherit;
127 //~^ ERROR use of deprecated item
128 //~^^ ERROR use of unstable
129 let _ = x.override1;
130 //~^ ERROR use of deprecated item
131 let _ = x.override2;
132 //~^ ERROR use of deprecated item
133 //~^^ ERROR use of unstable
134
135 let Deprecated {
136 //~^ ERROR use of deprecated item
137 //~^^ ERROR use of unstable
138 inherit: _,
139 //~^ ERROR use of deprecated item
140 //~^^ ERROR use of unstable
141 override1: _,
142 //~^ ERROR use of deprecated item
143 override2: _
144 //~^ ERROR use of unstable
145 //~^^ ERROR use of deprecated item
146 } = x;
147
148 let Deprecated
149 //~^ ERROR use of deprecated item
150 //~^^ ERROR use of unstable
151 // the patterns are all fine:
152 { .. } = x;
153
154 let x = Deprecated2(1, 2, 3);
155 //~^ ERROR use of deprecated item
156 //~^^ ERROR use of unstable
157
158 let _ = x.0;
159 //~^ ERROR use of deprecated item
160 //~^^ ERROR use of unstable
161 let _ = x.1;
162 //~^ ERROR use of deprecated item
163 let _ = x.2;
164 //~^ ERROR use of deprecated item
165 //~^^ ERROR use of unstable
166
167 let Deprecated2
168 //~^ ERROR use of deprecated item
169 //~^^ ERROR use of unstable
170 (_,
171 //~^ ERROR use of deprecated item
172 //~^^ ERROR use of unstable
173 _,
174 //~^ ERROR use of deprecated item
175 _)
176 //~^ ERROR use of deprecated item
177 //~^^ ERROR use of unstable
178 = x;
179 let Deprecated2
180 //~^ ERROR use of deprecated item
181 //~^^ ERROR use of unstable
182 // the patterns are all fine:
183 (..) = x;
184 }
185 }
186
187 mod this_crate {
188 #[stable(feature = "rust1", since = "1.0.0")]
189 struct Stable {
190 inherit: u8,
191 #[unstable(feature = "test_feature", issue = "0")]
192 override1: u8,
193 #[rustc_deprecated(since = "1.0.0", reason = "text")]
194 #[unstable(feature = "test_feature", issue = "0")]
195 override2: u8,
196 }
197
198 #[stable(feature = "rust1", since = "1.0.0")]
199 struct Stable2(u8,
200 #[stable(feature = "rust1", since = "1.0.0")] u8,
201 #[unstable(feature = "test_feature", issue = "0")]
202 #[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
203
204 #[unstable(feature = "test_feature", issue = "0")]
205 struct Unstable {
206 inherit: u8,
207 #[stable(feature = "rust1", since = "1.0.0")]
208 override1: u8,
209 #[rustc_deprecated(since = "1.0.0", reason = "text")]
210 #[unstable(feature = "test_feature", issue = "0")]
211 override2: u8,
212 }
213
214 #[unstable(feature = "test_feature", issue = "0")]
215 struct Unstable2(u8,
216 #[stable(feature = "rust1", since = "1.0.0")] u8,
217 #[unstable(feature = "test_feature", issue = "0")]
218 #[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
219
220 #[unstable(feature = "test_feature", issue = "0")]
221 #[rustc_deprecated(since = "1.0.0", reason = "text")]
222 struct Deprecated {
223 inherit: u8,
224 #[stable(feature = "rust1", since = "1.0.0")]
225 override1: u8,
226 #[unstable(feature = "test_feature", issue = "0")]
227 override2: u8,
228 }
229
230 #[unstable(feature = "test_feature", issue = "0")]
231 #[rustc_deprecated(since = "1.0.0", reason = "text")]
232 struct Deprecated2(u8,
233 #[stable(feature = "rust1", since = "1.0.0")] u8,
234 #[unstable(feature = "test_feature", issue = "0")] u8);
235
236 pub fn foo() {
237 let x = Stable {
238 inherit: 1,
239 override1: 2,
240 override2: 3,
241 //~^ ERROR use of deprecated item
242 };
243
244 let _ = x.inherit;
245 let _ = x.override1;
246 let _ = x.override2;
247 //~^ ERROR use of deprecated item
248
249 let Stable {
250 inherit: _,
251 override1: _,
252 override2: _
253 //~^ ERROR use of deprecated item
254 } = x;
255 // all fine
256 let Stable { .. } = x;
257
258 let x = Stable2(1, 2, 3);
259
260 let _ = x.0;
261 let _ = x.1;
262 let _ = x.2;
263 //~^ ERROR use of deprecated item
264
265 let Stable2(_,
266 _,
267 _)
268 //~^ ERROR use of deprecated item
269 = x;
270 // all fine
271 let Stable2(..) = x;
272
273
274 let x = Unstable {
275 inherit: 1,
276 override1: 2,
277 override2: 3,
278 //~^ ERROR use of deprecated item
279 };
280
281 let _ = x.inherit;
282 let _ = x.override1;
283 let _ = x.override2;
284 //~^ ERROR use of deprecated item
285
286 let Unstable {
287 inherit: _,
288 override1: _,
289 override2: _
290 //~^ ERROR use of deprecated item
291 } = x;
292
293 let Unstable
294 // the patterns are all fine:
295 { .. } = x;
296
297
298 let x = Unstable2(1, 2, 3);
299
300 let _ = x.0;
301 let _ = x.1;
302 let _ = x.2;
303 //~^ ERROR use of deprecated item
304
305 let Unstable2
306 (_,
307 _,
308 _)
309 //~^ ERROR use of deprecated item
310 = x;
311 let Unstable2
312 // the patterns are all fine:
313 (..) = x;
314
315
316 let x = Deprecated {
317 //~^ ERROR use of deprecated item
318 inherit: 1,
319 //~^ ERROR use of deprecated item
320 override1: 2,
321 //~^ ERROR use of deprecated item
322 override2: 3,
323 //~^ ERROR use of deprecated item
324 };
325
326 let _ = x.inherit;
327 //~^ ERROR use of deprecated item
328 let _ = x.override1;
329 //~^ ERROR use of deprecated item
330 let _ = x.override2;
331 //~^ ERROR use of deprecated item
332
333 let Deprecated {
334 //~^ ERROR use of deprecated item
335 inherit: _,
336 //~^ ERROR use of deprecated item
337 override1: _,
338 //~^ ERROR use of deprecated item
339 override2: _
340 //~^ ERROR use of deprecated item
341 } = x;
342
343 let Deprecated
344 //~^ ERROR use of deprecated item
345 // the patterns are all fine:
346 { .. } = x;
347
348 let x = Deprecated2(1, 2, 3);
349 //~^ ERROR use of deprecated item
350
351 let _ = x.0;
352 //~^ ERROR use of deprecated item
353 let _ = x.1;
354 //~^ ERROR use of deprecated item
355 let _ = x.2;
356 //~^ ERROR use of deprecated item
357
358 let Deprecated2
359 //~^ ERROR use of deprecated item
360 (_,
361 //~^ ERROR use of deprecated item
362 _,
363 //~^ ERROR use of deprecated item
364 _)
365 //~^ ERROR use of deprecated item
366 = x;
367 let Deprecated2
368 //~^ ERROR use of deprecated item
369 // the patterns are all fine:
370 (..) = x;
371 }
372 }
373
374 fn main() {}