1 // Copyright 2013-2014 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.
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.
11 // aux-build:lint_stability.rs
12 // aux-build:inherited_stability.rs
13 // aux-build:stability_cfg1.rs
14 // aux-build:stability_cfg2.rs
18 #![feature(staged_api)]
20 #![stable(feature = "rust1", since = "1.0.0")]
23 extern crate lint_stability
;
26 extern crate stability_cfg1
;
27 extern crate stability_cfg2
; //~ ERROR use of unstable library feature
29 use lint_stability
::*;
32 type Foo
= MethodTester
;
33 let foo
= MethodTester
;
35 deprecated(); //~ ERROR use of deprecated item
36 foo
.method_deprecated(); //~ ERROR use of deprecated item
37 Foo
::method_deprecated(&foo
); //~ ERROR use of deprecated item
38 <Foo
>::method_deprecated(&foo
); //~ ERROR use of deprecated item
39 foo
.trait_deprecated(); //~ ERROR use of deprecated item
40 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated item
41 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
42 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
44 deprecated_text(); //~ ERROR use of deprecated item: text
45 foo
.method_deprecated_text(); //~ ERROR use of deprecated item: text
46 Foo
::method_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
47 <Foo
>::method_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
48 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
49 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
50 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
51 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
53 deprecated_unstable(); //~ ERROR use of deprecated item
54 //~^ ERROR use of unstable library feature
55 foo
.method_deprecated_unstable(); //~ ERROR use of deprecated item
56 //~^ ERROR use of unstable library feature
57 Foo
::method_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
58 //~^ ERROR use of unstable library feature
59 <Foo
>::method_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
60 //~^ ERROR use of unstable library feature
61 foo
.trait_deprecated_unstable(); //~ ERROR use of deprecated item
62 //~^ ERROR use of unstable library feature
63 Trait
::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
64 //~^ ERROR use of unstable library feature
65 <Foo
>::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
66 //~^ ERROR use of unstable library feature
67 <Foo
as Trait
>::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
68 //~^ ERROR use of unstable library feature
70 deprecated_unstable_text(); //~ ERROR use of deprecated item: text
71 //~^ ERROR use of unstable library feature
72 foo
.method_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
73 //~^ ERROR use of unstable library feature
74 Foo
::method_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
75 //~^ ERROR use of unstable library feature
76 <Foo
>::method_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
77 //~^ ERROR use of unstable library feature
78 foo
.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
79 //~^ ERROR use of unstable library feature
80 Trait
::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
81 //~^ ERROR use of unstable library feature
82 <Foo
>::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
83 //~^ ERROR use of unstable library feature
84 <Foo
as Trait
>::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
85 //~^ ERROR use of unstable library feature
87 unstable(); //~ ERROR use of unstable library feature
88 foo
.method_unstable(); //~ ERROR use of unstable library feature
89 Foo
::method_unstable(&foo
); //~ ERROR use of unstable library feature
90 <Foo
>::method_unstable(&foo
); //~ ERROR use of unstable library feature
91 foo
.trait_unstable(); //~ ERROR use of unstable library feature
92 Trait
::trait_unstable(&foo
); //~ ERROR use of unstable library feature
93 <Foo
>::trait_unstable(&foo
); //~ ERROR use of unstable library feature
94 <Foo
as Trait
>::trait_unstable(&foo
); //~ ERROR use of unstable library feature
97 //~^ ERROR use of unstable library feature 'test_feature': text
98 foo
.method_unstable_text();
99 //~^ ERROR use of unstable library feature 'test_feature': text
100 Foo
::method_unstable_text(&foo
);
101 //~^ ERROR use of unstable library feature 'test_feature': text
102 <Foo
>::method_unstable_text(&foo
);
103 //~^ ERROR use of unstable library feature 'test_feature': text
104 foo
.trait_unstable_text();
105 //~^ ERROR use of unstable library feature 'test_feature': text
106 Trait
::trait_unstable_text(&foo
);
107 //~^ ERROR use of unstable library feature 'test_feature': text
108 <Foo
>::trait_unstable_text(&foo
);
109 //~^ ERROR use of unstable library feature 'test_feature': text
110 <Foo
as Trait
>::trait_unstable_text(&foo
);
111 //~^ ERROR use of unstable library feature 'test_feature': text
115 Foo
::method_stable(&foo
);
116 <Foo
>::method_stable(&foo
);
118 Trait
::trait_stable(&foo
);
119 <Foo
>::trait_stable(&foo
);
120 <Foo
as Trait
>::trait_stable(&foo
);
123 foo
.method_stable_text();
124 Foo
::method_stable_text(&foo
);
125 <Foo
>::method_stable_text(&foo
);
126 foo
.trait_stable_text();
127 Trait
::trait_stable_text(&foo
);
128 <Foo
>::trait_stable_text(&foo
);
129 <Foo
as Trait
>::trait_stable_text(&foo
);
131 let _
= DeprecatedStruct
{ //~ ERROR use of deprecated item
132 i
: 0 //~ ERROR use of deprecated item
134 let _
= DeprecatedUnstableStruct
{
135 //~^ ERROR use of deprecated item
136 //~^^ ERROR use of unstable library feature
137 i
: 0 //~ ERROR use of deprecated item
139 let _
= UnstableStruct { i: 0 }
; //~ ERROR use of unstable library feature
140 let _
= StableStruct { i: 0 }
;
142 let _
= DeprecatedUnitStruct
; //~ ERROR use of deprecated item
143 let _
= DeprecatedUnstableUnitStruct
; //~ ERROR use of deprecated item
144 //~^ ERROR use of unstable library feature
145 let _
= UnstableUnitStruct
; //~ ERROR use of unstable library feature
146 let _
= StableUnitStruct
;
148 let _
= Enum
::DeprecatedVariant
; //~ ERROR use of deprecated item
149 let _
= Enum
::DeprecatedUnstableVariant
; //~ ERROR use of deprecated item
150 //~^ ERROR use of unstable library feature
151 let _
= Enum
::UnstableVariant
; //~ ERROR use of unstable library feature
152 let _
= Enum
::StableVariant
;
154 let _
= DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
155 let _
= DeprecatedUnstableTupleStruct (1); //~ ERROR use of deprecated item
156 //~^ ERROR use of unstable library feature
157 let _
= UnstableTupleStruct (1); //~ ERROR use of unstable library feature
158 let _
= StableTupleStruct (1);
160 // At the moment, the lint checker only checks stability in
161 // in the arguments of macros.
162 // Eventually, we will want to lint the contents of the
163 // macro in the module *defining* it. Also, stability levels
164 // on macros themselves are not yet linted.
165 macro_test_arg
!(deprecated_text()); //~ ERROR use of deprecated item: text
166 macro_test_arg
!(deprecated_unstable_text()); //~ ERROR use of deprecated item: text
167 //~^ ERROR use of unstable library feature
168 macro_test_arg
!(macro_test_arg
!(deprecated_text())); //~ ERROR use of deprecated item: text
171 fn test_method_param
<Foo
: Trait
>(foo
: Foo
) {
172 foo
.trait_deprecated(); //~ ERROR use of deprecated item
173 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated item
174 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
175 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
176 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
177 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
178 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
179 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
180 foo
.trait_deprecated_unstable(); //~ ERROR use of deprecated item
181 //~^ ERROR use of unstable library feature
182 Trait
::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
183 //~^ ERROR use of unstable library feature
184 <Foo
>::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
185 //~^ ERROR use of unstable library feature
186 <Foo
as Trait
>::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
187 //~^ ERROR use of unstable library feature
188 foo
.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
189 //~^ ERROR use of unstable library feature
190 Trait
::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
191 //~^ ERROR use of unstable library feature
192 <Foo
>::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
193 //~^ ERROR use of unstable library feature
194 <Foo
as Trait
>::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
195 //~^ ERROR use of unstable library feature
196 foo
.trait_unstable(); //~ ERROR use of unstable library feature
197 Trait
::trait_unstable(&foo
); //~ ERROR use of unstable library feature
198 <Foo
>::trait_unstable(&foo
); //~ ERROR use of unstable library feature
199 <Foo
as Trait
>::trait_unstable(&foo
); //~ ERROR use of unstable library feature
200 foo
.trait_unstable_text();
201 //~^ ERROR use of unstable library feature 'test_feature': text
202 Trait
::trait_unstable_text(&foo
);
203 //~^ ERROR use of unstable library feature 'test_feature': text
204 <Foo
>::trait_unstable_text(&foo
);
205 //~^ ERROR use of unstable library feature 'test_feature': text
206 <Foo
as Trait
>::trait_unstable_text(&foo
);
207 //~^ ERROR use of unstable library feature 'test_feature': text
209 Trait
::trait_stable(&foo
);
210 <Foo
>::trait_stable(&foo
);
211 <Foo
as Trait
>::trait_stable(&foo
);
214 fn test_method_object(foo
: &Trait
) {
215 foo
.trait_deprecated(); //~ ERROR use of deprecated item
216 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
217 foo
.trait_deprecated_unstable(); //~ ERROR use of deprecated item
218 //~^ ERROR use of unstable library feature
219 foo
.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
220 //~^ ERROR use of unstable library feature
221 foo
.trait_unstable(); //~ ERROR use of unstable library feature
222 foo
.trait_unstable_text();
223 //~^ ERROR use of unstable library feature 'test_feature': text
229 impl UnstableTrait
for S { }
//~ ERROR use of unstable library feature
231 trait LocalTrait
: UnstableTrait { }
//~ ERROR use of unstable library feature
234 fn trait_stable(&self) {}
235 fn trait_unstable(&self) {}
//~ ERROR use of unstable library feature
240 extern crate inherited_stability
; //~ ERROR use of unstable library feature
241 use self::inherited_stability
::*; //~ ERROR use of unstable library feature
243 fn test_inheritance() {
244 unstable(); //~ ERROR use of unstable library feature
247 stable_mod
::unstable(); //~ ERROR use of unstable library feature
248 stable_mod
::stable();
250 unstable_mod
::deprecated(); //~ ERROR use of deprecated item
251 unstable_mod
::unstable(); //~ ERROR use of unstable library feature
253 let _
= Unstable
::UnstableVariant
; //~ ERROR use of unstable library feature
254 let _
= Unstable
::StableVariant
;
257 x
.unstable(); //~ ERROR use of unstable library feature
263 #[unstable(feature = "test_feature", issue = "0")]
264 #[rustc_deprecated(since = "1.0.0", reason = "text")]
265 pub fn deprecated() {}
266 #[unstable(feature = "test_feature", issue = "0")]
267 #[rustc_deprecated(since = "1.0.0", reason = "text")]
268 pub fn deprecated_text() {}
270 #[unstable(feature = "test_feature", issue = "0")]
272 #[unstable(feature = "test_feature", reason = "text", issue = "0")]
273 pub fn unstable_text() {}
275 #[stable(feature = "rust1", since = "1.0.0")]
277 #[stable(feature = "rust1", since = "1.0.0")]
278 pub fn stable_text() {}
280 #[stable(feature = "rust1", since = "1.0.0")]
281 pub struct MethodTester
;
284 #[unstable(feature = "test_feature", issue = "0")]
285 #[rustc_deprecated(since = "1.0.0", reason = "text")]
286 pub fn method_deprecated(&self) {}
287 #[unstable(feature = "test_feature", issue = "0")]
288 #[rustc_deprecated(since = "1.0.0", reason = "text")]
289 pub fn method_deprecated_text(&self) {}
291 #[unstable(feature = "test_feature", issue = "0")]
292 pub fn method_unstable(&self) {}
293 #[unstable(feature = "test_feature", reason = "text", issue = "0")]
294 pub fn method_unstable_text(&self) {}
296 #[stable(feature = "rust1", since = "1.0.0")]
297 pub fn method_stable(&self) {}
298 #[stable(feature = "rust1", since = "1.0.0")]
299 pub fn method_stable_text(&self) {}
303 #[unstable(feature = "test_feature", issue = "0")]
304 #[rustc_deprecated(since = "1.0.0", reason = "text")]
305 fn trait_deprecated(&self) {}
306 #[unstable(feature = "test_feature", issue = "0")]
307 #[rustc_deprecated(since = "1.0.0", reason = "text")]
308 fn trait_deprecated_text(&self) {}
310 #[unstable(feature = "test_feature", issue = "0")]
311 fn trait_unstable(&self) {}
312 #[unstable(feature = "test_feature", reason = "text", issue = "0")]
313 fn trait_unstable_text(&self) {}
315 #[stable(feature = "rust1", since = "1.0.0")]
316 fn trait_stable(&self) {}
317 #[stable(feature = "rust1", since = "1.0.0")]
318 fn trait_stable_text(&self) {}
321 impl Trait
for MethodTester {}
323 #[unstable(feature = "test_feature", issue = "0")]
324 #[rustc_deprecated(since = "1.0.0", reason = "text")]
325 pub struct DeprecatedStruct
{
326 #[stable(feature = "test_feature", since = "1.0.0")] i: isize
328 #[unstable(feature = "test_feature", issue = "0")]
329 pub struct UnstableStruct
{
330 #[stable(feature = "test_feature", since = "1.0.0")] i: isize
332 #[stable(feature = "rust1", since = "1.0.0")]
333 pub struct StableStruct
{
334 #[stable(feature = "test_feature", since = "1.0.0")] i: isize
337 #[unstable(feature = "test_feature", issue = "0")]
338 #[rustc_deprecated(since = "1.0.0", reason = "text")]
339 pub struct DeprecatedUnitStruct
;
340 #[unstable(feature = "test_feature", issue = "0")]
341 pub struct UnstableUnitStruct
;
342 #[stable(feature = "rust1", since = "1.0.0")]
343 pub struct StableUnitStruct
;
346 #[unstable(feature = "test_feature", issue = "0")]
347 #[rustc_deprecated(since = "1.0.0", reason = "text")]
349 #[unstable(feature = "test_feature", issue = "0")]
352 #[stable(feature = "rust1", since = "1.0.0")]
356 #[unstable(feature = "test_feature", issue = "0")]
357 #[rustc_deprecated(since = "1.0.0", reason = "text")]
358 pub struct DeprecatedTupleStruct(isize);
359 #[unstable(feature = "test_feature", issue = "0")]
360 pub struct UnstableTupleStruct(isize);
361 #[stable(feature = "rust1", since = "1.0.0")]
362 pub struct StableTupleStruct(isize);
365 // Only the deprecated cases of the following should generate
366 // errors, because other stability attributes now have meaning
367 // only *across* crates, not within a single crate.
369 type Foo
= MethodTester
;
370 let foo
= MethodTester
;
372 deprecated(); //~ ERROR use of deprecated item
373 foo
.method_deprecated(); //~ ERROR use of deprecated item
374 Foo
::method_deprecated(&foo
); //~ ERROR use of deprecated item
375 <Foo
>::method_deprecated(&foo
); //~ ERROR use of deprecated item
376 foo
.trait_deprecated(); //~ ERROR use of deprecated item
377 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated item
378 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
379 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
381 deprecated_text(); //~ ERROR use of deprecated item: text
382 foo
.method_deprecated_text(); //~ ERROR use of deprecated item: text
383 Foo
::method_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
384 <Foo
>::method_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
385 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
386 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
387 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
388 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
391 foo
.method_unstable();
392 Foo
::method_unstable(&foo
);
393 <Foo
>::method_unstable(&foo
);
394 foo
.trait_unstable();
395 Trait
::trait_unstable(&foo
);
396 <Foo
>::trait_unstable(&foo
);
397 <Foo
as Trait
>::trait_unstable(&foo
);
400 foo
.method_unstable_text();
401 Foo
::method_unstable_text(&foo
);
402 <Foo
>::method_unstable_text(&foo
);
403 foo
.trait_unstable_text();
404 Trait
::trait_unstable_text(&foo
);
405 <Foo
>::trait_unstable_text(&foo
);
406 <Foo
as Trait
>::trait_unstable_text(&foo
);
410 Foo
::method_stable(&foo
);
411 <Foo
>::method_stable(&foo
);
413 Trait
::trait_stable(&foo
);
414 <Foo
>::trait_stable(&foo
);
415 <Foo
as Trait
>::trait_stable(&foo
);
418 foo
.method_stable_text();
419 Foo
::method_stable_text(&foo
);
420 <Foo
>::method_stable_text(&foo
);
421 foo
.trait_stable_text();
422 Trait
::trait_stable_text(&foo
);
423 <Foo
>::trait_stable_text(&foo
);
424 <Foo
as Trait
>::trait_stable_text(&foo
);
426 let _
= DeprecatedStruct
{
427 //~^ ERROR use of deprecated item
428 i
: 0 //~ ERROR use of deprecated item
430 let _
= UnstableStruct { i: 0 }
;
431 let _
= StableStruct { i: 0 }
;
433 let _
= DeprecatedUnitStruct
; //~ ERROR use of deprecated item
434 let _
= UnstableUnitStruct
;
435 let _
= StableUnitStruct
;
437 let _
= Enum
::DeprecatedVariant
; //~ ERROR use of deprecated item
438 let _
= Enum
::UnstableVariant
;
439 let _
= Enum
::StableVariant
;
441 let _
= DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
442 let _
= UnstableTupleStruct (1);
443 let _
= StableTupleStruct (1);
446 fn test_method_param
<Foo
: Trait
>(foo
: Foo
) {
447 foo
.trait_deprecated(); //~ ERROR use of deprecated item
448 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated item
449 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
450 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
451 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
452 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
453 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
454 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
455 foo
.trait_unstable();
456 Trait
::trait_unstable(&foo
);
457 <Foo
>::trait_unstable(&foo
);
458 <Foo
as Trait
>::trait_unstable(&foo
);
459 foo
.trait_unstable_text();
460 Trait
::trait_unstable_text(&foo
);
461 <Foo
>::trait_unstable_text(&foo
);
462 <Foo
as Trait
>::trait_unstable_text(&foo
);
464 Trait
::trait_stable(&foo
);
465 <Foo
>::trait_stable(&foo
);
466 <Foo
as Trait
>::trait_stable(&foo
);
469 fn test_method_object(foo
: &Trait
) {
470 foo
.trait_deprecated(); //~ ERROR use of deprecated item
471 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
472 foo
.trait_unstable();
473 foo
.trait_unstable_text();
477 #[unstable(feature = "test_feature", issue = "0")]
478 #[rustc_deprecated(since = "1.0.0", reason = "text")]
481 fn_in_body(); //~ ERROR use of deprecated item: text
485 #[unstable(feature = "test_feature", issue = "0")]
486 #[rustc_deprecated(since = "1.0.0", reason = "text")]
487 fn test_method_body(&self) {
489 fn_in_body(); //~ ERROR use of deprecated item: text
493 #[unstable(feature = "test_feature", issue = "0")]
494 #[rustc_deprecated(since = "1.0.0", reason = "text")]
495 pub trait DeprecatedTrait
{
501 impl DeprecatedTrait
for S { }
//~ ERROR use of deprecated item
503 trait LocalTrait
: DeprecatedTrait { }
//~ ERROR use of deprecated item