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)]
22 extern crate lint_stability
;
25 extern crate stability_cfg1
;
26 extern crate stability_cfg2
; //~ ERROR use of unstable library feature
28 use lint_stability
::*;
31 type Foo
= MethodTester
;
32 let foo
= MethodTester
;
34 deprecated(); //~ ERROR use of deprecated item
35 foo
.method_deprecated(); //~ ERROR use of deprecated item
36 Foo
::method_deprecated(&foo
); //~ ERROR use of deprecated item
37 <Foo
>::method_deprecated(&foo
); //~ ERROR use of deprecated item
38 foo
.trait_deprecated(); //~ ERROR use of deprecated item
39 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated item
40 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
41 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
43 deprecated_text(); //~ ERROR use of deprecated item: text
44 foo
.method_deprecated_text(); //~ ERROR use of deprecated item: text
45 Foo
::method_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
46 <Foo
>::method_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
47 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
48 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
49 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
50 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
52 deprecated_unstable(); //~ ERROR use of deprecated item
53 //~^ ERROR use of unstable library feature
54 foo
.method_deprecated_unstable(); //~ ERROR use of deprecated item
55 //~^ ERROR use of unstable library feature
56 Foo
::method_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
57 //~^ ERROR use of unstable library feature
58 <Foo
>::method_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
59 //~^ ERROR use of unstable library feature
60 foo
.trait_deprecated_unstable(); //~ ERROR use of deprecated item
61 //~^ ERROR use of unstable library feature
62 Trait
::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
63 //~^ ERROR use of unstable library feature
64 <Foo
>::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
65 //~^ ERROR use of unstable library feature
66 <Foo
as Trait
>::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
67 //~^ ERROR use of unstable library feature
69 deprecated_unstable_text(); //~ ERROR use of deprecated item: text
70 //~^ ERROR use of unstable library feature
71 foo
.method_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
72 //~^ ERROR use of unstable library feature
73 Foo
::method_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
74 //~^ ERROR use of unstable library feature
75 <Foo
>::method_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
76 //~^ ERROR use of unstable library feature
77 foo
.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
78 //~^ ERROR use of unstable library feature
79 Trait
::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
80 //~^ ERROR use of unstable library feature
81 <Foo
>::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
82 //~^ ERROR use of unstable library feature
83 <Foo
as Trait
>::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
84 //~^ ERROR use of unstable library feature
86 unstable(); //~ ERROR use of unstable library feature
87 foo
.method_unstable(); //~ ERROR use of unstable library feature
88 Foo
::method_unstable(&foo
); //~ ERROR use of unstable library feature
89 <Foo
>::method_unstable(&foo
); //~ ERROR use of unstable library feature
90 foo
.trait_unstable(); //~ ERROR use of unstable library feature
91 Trait
::trait_unstable(&foo
); //~ ERROR use of unstable library feature
92 <Foo
>::trait_unstable(&foo
); //~ ERROR use of unstable library feature
93 <Foo
as Trait
>::trait_unstable(&foo
); //~ ERROR use of unstable library feature
96 //~^ ERROR use of unstable library feature 'test_feature': text
97 foo
.method_unstable_text();
98 //~^ ERROR use of unstable library feature 'test_feature': text
99 Foo
::method_unstable_text(&foo
);
100 //~^ ERROR use of unstable library feature 'test_feature': text
101 <Foo
>::method_unstable_text(&foo
);
102 //~^ ERROR use of unstable library feature 'test_feature': text
103 foo
.trait_unstable_text();
104 //~^ ERROR use of unstable library feature 'test_feature': text
105 Trait
::trait_unstable_text(&foo
);
106 //~^ ERROR use of unstable library feature 'test_feature': text
107 <Foo
>::trait_unstable_text(&foo
);
108 //~^ ERROR use of unstable library feature 'test_feature': text
109 <Foo
as Trait
>::trait_unstable_text(&foo
);
110 //~^ ERROR use of unstable library feature 'test_feature': text
114 Foo
::method_stable(&foo
);
115 <Foo
>::method_stable(&foo
);
117 Trait
::trait_stable(&foo
);
118 <Foo
>::trait_stable(&foo
);
119 <Foo
as Trait
>::trait_stable(&foo
);
122 foo
.method_stable_text();
123 Foo
::method_stable_text(&foo
);
124 <Foo
>::method_stable_text(&foo
);
125 foo
.trait_stable_text();
126 Trait
::trait_stable_text(&foo
);
127 <Foo
>::trait_stable_text(&foo
);
128 <Foo
as Trait
>::trait_stable_text(&foo
);
130 let _
= DeprecatedStruct { i: 0 }
; //~ ERROR use of deprecated item
131 let _
= DeprecatedUnstableStruct { i: 0 }
; //~ ERROR use of deprecated item
132 //~^ ERROR use of unstable library feature
133 let _
= UnstableStruct { i: 0 }
; //~ ERROR use of unstable library feature
134 let _
= StableStruct { i: 0 }
;
136 let _
= DeprecatedUnitStruct
; //~ ERROR use of deprecated item
137 let _
= DeprecatedUnstableUnitStruct
; //~ ERROR use of deprecated item
138 //~^ ERROR use of unstable library feature
139 let _
= UnstableUnitStruct
; //~ ERROR use of unstable library feature
140 let _
= StableUnitStruct
;
142 let _
= Enum
::DeprecatedVariant
; //~ ERROR use of deprecated item
143 let _
= Enum
::DeprecatedUnstableVariant
; //~ ERROR use of deprecated item
144 //~^ ERROR use of unstable library feature
145 let _
= Enum
::UnstableVariant
; //~ ERROR use of unstable library feature
146 let _
= Enum
::StableVariant
;
148 let _
= DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
149 let _
= DeprecatedUnstableTupleStruct (1); //~ ERROR use of deprecated item
150 //~^ ERROR use of unstable library feature
151 let _
= UnstableTupleStruct (1); //~ ERROR use of unstable library feature
152 let _
= StableTupleStruct (1);
154 // At the moment, the lint checker only checks stability in
155 // in the arguments of macros.
156 // Eventually, we will want to lint the contents of the
157 // macro in the module *defining* it. Also, stability levels
158 // on macros themselves are not yet linted.
159 macro_test_arg
!(deprecated_text()); //~ ERROR use of deprecated item: text
160 macro_test_arg
!(deprecated_unstable_text()); //~ ERROR use of deprecated item: text
161 //~^ ERROR use of unstable library feature
162 macro_test_arg
!(macro_test_arg
!(deprecated_text())); //~ ERROR use of deprecated item: text
165 fn test_method_param
<Foo
: Trait
>(foo
: Foo
) {
166 foo
.trait_deprecated(); //~ ERROR use of deprecated item
167 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated item
168 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
169 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
170 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
171 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
172 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
173 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
174 foo
.trait_deprecated_unstable(); //~ ERROR use of deprecated item
175 //~^ ERROR use of unstable library feature
176 Trait
::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
177 //~^ ERROR use of unstable library feature
178 <Foo
>::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
179 //~^ ERROR use of unstable library feature
180 <Foo
as Trait
>::trait_deprecated_unstable(&foo
); //~ ERROR use of deprecated item
181 //~^ ERROR use of unstable library feature
182 foo
.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
183 //~^ ERROR use of unstable library feature
184 Trait
::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
185 //~^ ERROR use of unstable library feature
186 <Foo
>::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
187 //~^ ERROR use of unstable library feature
188 <Foo
as Trait
>::trait_deprecated_unstable_text(&foo
); //~ ERROR use of deprecated item: text
189 //~^ ERROR use of unstable library feature
190 foo
.trait_unstable(); //~ ERROR use of unstable library feature
191 Trait
::trait_unstable(&foo
); //~ ERROR use of unstable library feature
192 <Foo
>::trait_unstable(&foo
); //~ ERROR use of unstable library feature
193 <Foo
as Trait
>::trait_unstable(&foo
); //~ ERROR use of unstable library feature
194 foo
.trait_unstable_text();
195 //~^ ERROR use of unstable library feature 'test_feature': text
196 Trait
::trait_unstable_text(&foo
);
197 //~^ ERROR use of unstable library feature 'test_feature': text
198 <Foo
>::trait_unstable_text(&foo
);
199 //~^ ERROR use of unstable library feature 'test_feature': text
200 <Foo
as Trait
>::trait_unstable_text(&foo
);
201 //~^ ERROR use of unstable library feature 'test_feature': text
203 Trait
::trait_stable(&foo
);
204 <Foo
>::trait_stable(&foo
);
205 <Foo
as Trait
>::trait_stable(&foo
);
208 fn test_method_object(foo
: &Trait
) {
209 foo
.trait_deprecated(); //~ ERROR use of deprecated item
210 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
211 foo
.trait_deprecated_unstable(); //~ ERROR use of deprecated item
212 //~^ ERROR use of unstable library feature
213 foo
.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
214 //~^ ERROR use of unstable library feature
215 foo
.trait_unstable(); //~ ERROR use of unstable library feature
216 foo
.trait_unstable_text();
217 //~^ ERROR use of unstable library feature 'test_feature': text
223 impl UnstableTrait
for S { }
//~ ERROR use of unstable library feature
225 trait LocalTrait
: UnstableTrait { }
//~ ERROR use of unstable library feature
228 fn trait_stable(&self) {}
229 fn trait_unstable(&self) {}
//~ ERROR use of unstable library feature
234 extern crate inherited_stability
; //~ ERROR use of unstable library feature
235 use self::inherited_stability
::*; //~ ERROR use of unstable library feature
237 fn test_inheritance() {
238 unstable(); //~ ERROR use of unstable library feature
241 stable_mod
::unstable(); //~ ERROR use of unstable library feature
242 stable_mod
::stable();
244 unstable_mod
::deprecated(); //~ ERROR use of deprecated item
245 unstable_mod
::unstable(); //~ ERROR use of unstable library feature
247 let _
= Unstable
::UnstableVariant
; //~ ERROR use of unstable library feature
248 let _
= Unstable
::StableVariant
;
251 x
.unstable(); //~ ERROR use of unstable library feature
257 #[unstable(feature = "test_feature")]
258 #[deprecated(since = "1.0.0")]
259 pub fn deprecated() {}
260 #[unstable(feature = "test_feature")]
261 #[deprecated(since = "1.0.0", reason = "text")]
262 pub fn deprecated_text() {}
264 #[unstable(feature = "test_feature")]
266 #[unstable(feature = "test_feature", reason = "text")]
267 pub fn unstable_text() {}
269 #[stable(feature = "rust1", since = "1.0.0")]
271 #[stable(feature = "rust1", since = "1.0.0", reason = "text")]
272 pub fn stable_text() {}
274 #[stable(feature = "rust1", since = "1.0.0")]
275 pub struct MethodTester
;
278 #[unstable(feature = "test_feature")]
279 #[deprecated(since = "1.0.0")]
280 pub fn method_deprecated(&self) {}
281 #[unstable(feature = "test_feature")]
282 #[deprecated(since = "1.0.0", reason = "text")]
283 pub fn method_deprecated_text(&self) {}
285 #[unstable(feature = "test_feature")]
286 pub fn method_unstable(&self) {}
287 #[unstable(feature = "test_feature", reason = "text")]
288 pub fn method_unstable_text(&self) {}
290 #[stable(feature = "rust1", since = "1.0.0")]
291 pub fn method_stable(&self) {}
292 #[stable(feature = "rust1", since = "1.0.0", reason = "text")]
293 pub fn method_stable_text(&self) {}
297 #[unstable(feature = "test_feature")]
298 #[deprecated(since = "1.0.0")]
299 fn trait_deprecated(&self) {}
300 #[unstable(feature = "test_feature")]
301 #[deprecated(since = "1.0.0", reason = "text")]
302 fn trait_deprecated_text(&self) {}
304 #[unstable(feature = "test_feature")]
305 fn trait_unstable(&self) {}
306 #[unstable(feature = "test_feature", reason = "text")]
307 fn trait_unstable_text(&self) {}
309 #[stable(feature = "rust1", since = "1.0.0")]
310 fn trait_stable(&self) {}
311 #[stable(feature = "rust1", since = "1.0.0", reason = "text")]
312 fn trait_stable_text(&self) {}
315 impl Trait
for MethodTester {}
317 #[unstable(feature = "test_feature")]
318 #[deprecated(since = "1.0.0")]
319 pub struct DeprecatedStruct
{
320 #[stable(feature = "test_feature", since = "1.0.0")] i: isize
322 #[unstable(feature = "test_feature")]
323 pub struct UnstableStruct
{
324 #[stable(feature = "test_feature", since = "1.0.0")] i: isize
326 #[stable(feature = "rust1", since = "1.0.0")]
327 pub struct StableStruct
{
328 #[stable(feature = "test_feature", since = "1.0.0")] i: isize
331 #[unstable(feature = "test_feature")]
332 #[deprecated(since = "1.0.0")]
333 pub struct DeprecatedUnitStruct
;
334 #[unstable(feature = "test_feature")]
335 pub struct UnstableUnitStruct
;
336 #[stable(feature = "rust1", since = "1.0.0")]
337 pub struct StableUnitStruct
;
340 #[unstable(feature = "test_feature")]
341 #[deprecated(since = "1.0.0")]
343 #[unstable(feature = "test_feature")]
346 #[stable(feature = "rust1", since = "1.0.0")]
350 #[unstable(feature = "test_feature")]
351 #[deprecated(since = "1.0.0")]
352 pub struct DeprecatedTupleStruct(isize);
353 #[unstable(feature = "test_feature")]
354 pub struct UnstableTupleStruct(isize);
355 #[stable(feature = "rust1", since = "1.0.0")]
356 pub struct StableTupleStruct(isize);
359 // Only the deprecated cases of the following should generate
360 // errors, because other stability attributes now have meaning
361 // only *across* crates, not within a single crate.
363 type Foo
= MethodTester
;
364 let foo
= MethodTester
;
366 deprecated(); //~ ERROR use of deprecated item
367 foo
.method_deprecated(); //~ ERROR use of deprecated item
368 Foo
::method_deprecated(&foo
); //~ ERROR use of deprecated item
369 <Foo
>::method_deprecated(&foo
); //~ ERROR use of deprecated item
370 foo
.trait_deprecated(); //~ ERROR use of deprecated item
371 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated item
372 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
373 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
375 deprecated_text(); //~ ERROR use of deprecated item: text
376 foo
.method_deprecated_text(); //~ ERROR use of deprecated item: text
377 Foo
::method_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
378 <Foo
>::method_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
379 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
380 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
381 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
382 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
385 foo
.method_unstable();
386 Foo
::method_unstable(&foo
);
387 <Foo
>::method_unstable(&foo
);
388 foo
.trait_unstable();
389 Trait
::trait_unstable(&foo
);
390 <Foo
>::trait_unstable(&foo
);
391 <Foo
as Trait
>::trait_unstable(&foo
);
394 foo
.method_unstable_text();
395 Foo
::method_unstable_text(&foo
);
396 <Foo
>::method_unstable_text(&foo
);
397 foo
.trait_unstable_text();
398 Trait
::trait_unstable_text(&foo
);
399 <Foo
>::trait_unstable_text(&foo
);
400 <Foo
as Trait
>::trait_unstable_text(&foo
);
404 Foo
::method_stable(&foo
);
405 <Foo
>::method_stable(&foo
);
407 Trait
::trait_stable(&foo
);
408 <Foo
>::trait_stable(&foo
);
409 <Foo
as Trait
>::trait_stable(&foo
);
412 foo
.method_stable_text();
413 Foo
::method_stable_text(&foo
);
414 <Foo
>::method_stable_text(&foo
);
415 foo
.trait_stable_text();
416 Trait
::trait_stable_text(&foo
);
417 <Foo
>::trait_stable_text(&foo
);
418 <Foo
as Trait
>::trait_stable_text(&foo
);
420 let _
= DeprecatedStruct { i: 0 }
; //~ ERROR use of deprecated item
421 let _
= UnstableStruct { i: 0 }
;
422 let _
= StableStruct { i: 0 }
;
424 let _
= DeprecatedUnitStruct
; //~ ERROR use of deprecated item
425 let _
= UnstableUnitStruct
;
426 let _
= StableUnitStruct
;
428 let _
= Enum
::DeprecatedVariant
; //~ ERROR use of deprecated item
429 let _
= Enum
::UnstableVariant
;
430 let _
= Enum
::StableVariant
;
432 let _
= DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
433 let _
= UnstableTupleStruct (1);
434 let _
= StableTupleStruct (1);
437 fn test_method_param
<Foo
: Trait
>(foo
: Foo
) {
438 foo
.trait_deprecated(); //~ ERROR use of deprecated item
439 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated item
440 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
441 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated item
442 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
443 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
444 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
445 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated item: text
446 foo
.trait_unstable();
447 Trait
::trait_unstable(&foo
);
448 <Foo
>::trait_unstable(&foo
);
449 <Foo
as Trait
>::trait_unstable(&foo
);
450 foo
.trait_unstable_text();
451 Trait
::trait_unstable_text(&foo
);
452 <Foo
>::trait_unstable_text(&foo
);
453 <Foo
as Trait
>::trait_unstable_text(&foo
);
455 Trait
::trait_stable(&foo
);
456 <Foo
>::trait_stable(&foo
);
457 <Foo
as Trait
>::trait_stable(&foo
);
460 fn test_method_object(foo
: &Trait
) {
461 foo
.trait_deprecated(); //~ ERROR use of deprecated item
462 foo
.trait_deprecated_text(); //~ ERROR use of deprecated item: text
463 foo
.trait_unstable();
464 foo
.trait_unstable_text();
468 #[unstable(feature = "test_feature")]
469 #[deprecated(since = "1.0.0")]
476 #[unstable(feature = "test_feature")]
477 #[deprecated(since = "1.0.0")]
478 fn test_method_body(&self) {
484 #[unstable(feature = "test_feature")]
485 #[deprecated(since = "1.0.0")]
486 pub trait DeprecatedTrait
{
492 impl DeprecatedTrait
for S { }
//~ ERROR use of deprecated item
494 trait LocalTrait
: DeprecatedTrait { }
//~ ERROR use of deprecated item