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