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
19 #![deny(experimental)]
23 extern crate lint_stability; //~ ERROR: use of unmarked item
26 extern crate stability_cfg1;
27 extern crate stability_cfg2; //~ ERROR: use of experimental item
29 use lint_stability::*;
32 let foo = MethodTester;
34 deprecated(); //~ ERROR use of deprecated item
35 foo.method_deprecated(); //~ ERROR use of deprecated item
36 foo.trait_deprecated(); //~ ERROR use of deprecated item
38 deprecated_text(); //~ ERROR use of deprecated item: text
39 foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
40 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
42 experimental(); //~ ERROR use of experimental item
43 foo.method_experimental(); //~ ERROR use of experimental item
44 foo.trait_experimental(); //~ ERROR use of experimental item
46 experimental_text(); //~ ERROR use of experimental item: text
47 foo.method_experimental_text(); //~ ERROR use of experimental item: text
48 foo.trait_experimental_text(); //~ ERROR use of experimental item: text
50 unstable(); //~ ERROR use of unstable item
51 foo.method_unstable(); //~ ERROR use of unstable item
52 foo.trait_unstable(); //~ ERROR use of unstable item
54 unstable_text(); //~ ERROR use of unstable item: text
55 foo.method_unstable_text(); //~ ERROR use of unstable item: text
56 foo.trait_unstable_text(); //~ ERROR use of unstable item: text
58 unmarked(); //~ ERROR use of unmarked item
59 foo.method_unmarked(); //~ ERROR use of unmarked item
60 foo.trait_unmarked(); //~ ERROR use of unmarked item
67 foo.method_stable_text();
68 foo.trait_stable_text();
75 foo.method_frozen_text();
76 foo.trait_frozen_text();
83 foo.method_locked_text();
84 foo.trait_locked_text();
86 let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item
87 let _ = ExperimentalStruct { i: 0 }; //~ ERROR use of experimental item
88 let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable item
89 let _ = UnmarkedStruct { i: 0 }; //~ ERROR use of unmarked item
90 let _ = StableStruct { i: 0 };
91 let _ = FrozenStruct { i: 0 };
92 let _ = LockedStruct { i: 0 };
94 let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
95 let _ = ExperimentalUnitStruct; //~ ERROR use of experimental item
96 let _ = UnstableUnitStruct; //~ ERROR use of unstable item
97 let _ = UnmarkedUnitStruct; //~ ERROR use of unmarked item
98 let _ = StableUnitStruct;
99 let _ = FrozenUnitStruct;
100 let _ = LockedUnitStruct;
102 let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
103 let _ = Enum::ExperimentalVariant; //~ ERROR use of experimental item
104 let _ = Enum::UnstableVariant; //~ ERROR use of unstable item
105 let _ = Enum::UnmarkedVariant; //~ ERROR use of unmarked item
106 let _ = Enum::StableVariant;
107 let _ = Enum::FrozenVariant;
108 let _ = Enum::LockedVariant;
110 let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
111 let _ = ExperimentalTupleStruct (1); //~ ERROR use of experimental item
112 let _ = UnstableTupleStruct (1); //~ ERROR use of unstable item
113 let _ = UnmarkedTupleStruct (1); //~ ERROR use of unmarked item
114 let _ = StableTupleStruct (1);
115 let _ = FrozenTupleStruct (1);
116 let _ = LockedTupleStruct (1);
118 // At the moment, the lint checker only checks stability in
119 // in the arguments of macros.
120 // Eventually, we will want to lint the contents of the
121 // macro in the module *defining* it. Also, stability levels
122 // on macros themselves are not yet linted.
124 macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item: text
125 macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated item: text
126 macro_test_arg_nested!(deprecated_text);
129 fn test_method_param<F: Trait>(foo: F) {
130 foo.trait_deprecated(); //~ ERROR use of deprecated item
131 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
132 foo.trait_experimental(); //~ ERROR use of experimental item
133 foo.trait_experimental_text(); //~ ERROR use of experimental item: text
134 foo.trait_unstable(); //~ ERROR use of unstable item
135 foo.trait_unstable_text(); //~ ERROR use of unstable item: text
136 foo.trait_unmarked(); //~ ERROR use of unmarked item
140 fn test_method_object(foo: &Trait) {
141 foo.trait_deprecated(); //~ ERROR use of deprecated item
142 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
143 foo.trait_experimental(); //~ ERROR use of experimental item
144 foo.trait_experimental_text(); //~ ERROR use of experimental item: text
145 foo.trait_unstable(); //~ ERROR use of unstable item
146 foo.trait_unstable_text(); //~ ERROR use of unstable item: text
147 foo.trait_unmarked(); //~ ERROR use of unmarked item
153 impl ExperimentalTrait for S { } //~ ERROR use of experimental item
155 trait LocalTrait : ExperimentalTrait { } //~ ERROR use of experimental item
159 extern crate inherited_stability; //~ ERROR: use of experimental item
160 use self::inherited_stability::*;
162 fn test_inheritance() {
163 experimental(); //~ ERROR use of experimental item
166 stable_mod::experimental(); //~ ERROR use of experimental item
167 stable_mod::stable();
169 unstable_mod::experimental(); //~ ERROR use of experimental item
170 unstable_mod::unstable(); //~ ERROR use of unstable item
172 experimental_mod::experimental(); //~ ERROR use of experimental item
173 experimental_mod::stable();
175 let _ = Experimental::ExperimentalVariant; //~ ERROR use of experimental item
176 let _ = Experimental::StableVariant;
179 x.experimental(); //~ ERROR use of experimental item
186 pub fn deprecated() {}
188 pub fn deprecated_text() {}
191 pub fn experimental() {}
192 #[experimental="text"]
193 pub fn experimental_text() {}
198 pub fn unstable_text() {}
205 pub fn stable_text() {}
210 pub fn locked_text() {}
215 pub fn frozen_text() {}
218 pub struct MethodTester;
222 pub fn method_deprecated(&self) {}
224 pub fn method_deprecated_text(&self) {}
227 pub fn method_experimental(&self) {}
228 #[experimental="text"]
229 pub fn method_experimental_text(&self) {}
232 pub fn method_unstable(&self) {}
234 pub fn method_unstable_text(&self) {}
236 pub fn method_unmarked(&self) {}
239 pub fn method_stable(&self) {}
241 pub fn method_stable_text(&self) {}
244 pub fn method_locked(&self) {}
246 pub fn method_locked_text(&self) {}
249 pub fn method_frozen(&self) {}
251 pub fn method_frozen_text(&self) {}
256 fn trait_deprecated(&self) {}
258 fn trait_deprecated_text(&self) {}
261 fn trait_experimental(&self) {}
262 #[experimental="text"]
263 fn trait_experimental_text(&self) {}
266 fn trait_unstable(&self) {}
268 fn trait_unstable_text(&self) {}
270 fn trait_unmarked(&self) {}
273 fn trait_stable(&self) {}
275 fn trait_stable_text(&self) {}
278 fn trait_locked(&self) {}
280 fn trait_locked_text(&self) {}
283 fn trait_frozen(&self) {}
285 fn trait_frozen_text(&self) {}
288 impl Trait for MethodTester {}
291 pub struct DeprecatedStruct { i: int }
293 pub struct ExperimentalStruct { i: int }
295 pub struct UnstableStruct { i: int }
296 pub struct UnmarkedStruct { i: int }
298 pub struct StableStruct { i: int }
300 pub struct FrozenStruct { i: int }
302 pub struct LockedStruct { i: int }
305 pub struct DeprecatedUnitStruct;
307 pub struct ExperimentalUnitStruct;
309 pub struct UnstableUnitStruct;
310 pub struct UnmarkedUnitStruct;
312 pub struct StableUnitStruct;
314 pub struct FrozenUnitStruct;
316 pub struct LockedUnitStruct;
336 pub struct DeprecatedTupleStruct(int);
338 pub struct ExperimentalTupleStruct(int);
340 pub struct UnstableTupleStruct(int);
341 pub struct UnmarkedTupleStruct(int);
343 pub struct StableTupleStruct(int);
345 pub struct FrozenTupleStruct(int);
347 pub struct LockedTupleStruct(int);
350 // Only the deprecated cases of the following should generate
351 // errors, because other stability attributes now have meaning
352 // only *across* crates, not within a single crate.
354 let foo = MethodTester;
356 deprecated(); //~ ERROR use of deprecated item
357 foo.method_deprecated(); //~ ERROR use of deprecated item
358 foo.trait_deprecated(); //~ ERROR use of deprecated item
360 deprecated_text(); //~ ERROR use of deprecated item: text
361 foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
362 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
365 foo.method_experimental();
366 foo.trait_experimental();
369 foo.method_experimental_text();
370 foo.trait_experimental_text();
373 foo.method_unstable();
374 foo.trait_unstable();
377 foo.method_unstable_text();
378 foo.trait_unstable_text();
381 foo.method_unmarked();
382 foo.trait_unmarked();
389 foo.method_stable_text();
390 foo.trait_stable_text();
397 foo.method_frozen_text();
398 foo.trait_frozen_text();
405 foo.method_locked_text();
406 foo.trait_locked_text();
408 let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item
409 let _ = ExperimentalStruct { i: 0 };
410 let _ = UnstableStruct { i: 0 };
411 let _ = UnmarkedStruct { i: 0 };
412 let _ = StableStruct { i: 0 };
413 let _ = FrozenStruct { i: 0 };
414 let _ = LockedStruct { i: 0 };
416 let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
417 let _ = ExperimentalUnitStruct;
418 let _ = UnstableUnitStruct;
419 let _ = UnmarkedUnitStruct;
420 let _ = StableUnitStruct;
421 let _ = FrozenUnitStruct;
422 let _ = LockedUnitStruct;
424 let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
425 let _ = Enum::ExperimentalVariant;
426 let _ = Enum::UnstableVariant;
427 let _ = Enum::UnmarkedVariant;
428 let _ = Enum::StableVariant;
429 let _ = Enum::FrozenVariant;
430 let _ = Enum::LockedVariant;
432 let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
433 let _ = ExperimentalTupleStruct (1);
434 let _ = UnstableTupleStruct (1);
435 let _ = UnmarkedTupleStruct (1);
436 let _ = StableTupleStruct (1);
437 let _ = FrozenTupleStruct (1);
438 let _ = LockedTupleStruct (1);
441 fn test_method_param<F: Trait>(foo: F) {
442 foo.trait_deprecated(); //~ ERROR use of deprecated item
443 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
444 foo.trait_experimental();
445 foo.trait_experimental_text();
446 foo.trait_unstable();
447 foo.trait_unstable_text();
448 foo.trait_unmarked();
452 fn test_method_object(foo: &Trait) {
453 foo.trait_deprecated(); //~ ERROR use of deprecated item
454 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
455 foo.trait_experimental();
456 foo.trait_experimental_text();
457 foo.trait_unstable();
458 foo.trait_unstable_text();
459 foo.trait_unmarked();
471 fn test_method_body(&self) {
478 pub trait DeprecatedTrait {}
482 impl DeprecatedTrait for S { } //~ ERROR use of deprecated item
484 trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item