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 #![deny(experimental)]
22 extern crate lint_stability; //~ ERROR: use of unmarked item
25 extern crate stability_cfg1;
26 extern crate stability_cfg2; //~ ERROR: use of experimental item
28 use lint_stability::*;
31 let foo = MethodTester;
33 deprecated(); //~ ERROR use of deprecated item
34 foo.method_deprecated(); //~ ERROR use of deprecated item
35 foo.trait_deprecated(); //~ ERROR use of deprecated item
37 deprecated_text(); //~ ERROR use of deprecated item: text
38 foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
39 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
41 experimental(); //~ ERROR use of experimental item
42 foo.method_experimental(); //~ ERROR use of experimental item
43 foo.trait_experimental(); //~ ERROR use of experimental item
45 experimental_text(); //~ ERROR use of experimental item: text
46 foo.method_experimental_text(); //~ ERROR use of experimental item: text
47 foo.trait_experimental_text(); //~ ERROR use of experimental item: text
49 unstable(); //~ ERROR use of unstable item
50 foo.method_unstable(); //~ ERROR use of unstable item
51 foo.trait_unstable(); //~ ERROR use of unstable item
53 unstable_text(); //~ ERROR use of unstable item: text
54 foo.method_unstable_text(); //~ ERROR use of unstable item: text
55 foo.trait_unstable_text(); //~ ERROR use of unstable item: text
57 unmarked(); //~ ERROR use of unmarked item
58 foo.method_unmarked(); //~ ERROR use of unmarked item
59 foo.trait_unmarked(); //~ ERROR use of unmarked item
66 foo.method_stable_text();
67 foo.trait_stable_text();
74 foo.method_frozen_text();
75 foo.trait_frozen_text();
82 foo.method_locked_text();
83 foo.trait_locked_text();
85 let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item
86 let _ = ExperimentalStruct { i: 0 }; //~ ERROR use of experimental item
87 let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable item
88 let _ = UnmarkedStruct { i: 0 }; //~ ERROR use of unmarked item
89 let _ = StableStruct { i: 0 };
90 let _ = FrozenStruct { i: 0 };
91 let _ = LockedStruct { i: 0 };
93 let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
94 let _ = ExperimentalUnitStruct; //~ ERROR use of experimental item
95 let _ = UnstableUnitStruct; //~ ERROR use of unstable item
96 let _ = UnmarkedUnitStruct; //~ ERROR use of unmarked item
97 let _ = StableUnitStruct;
98 let _ = FrozenUnitStruct;
99 let _ = LockedUnitStruct;
101 let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
102 let _ = Enum::ExperimentalVariant; //~ ERROR use of experimental item
103 let _ = Enum::UnstableVariant; //~ ERROR use of unstable item
104 let _ = Enum::UnmarkedVariant; //~ ERROR use of unmarked item
105 let _ = Enum::StableVariant;
106 let _ = Enum::FrozenVariant;
107 let _ = Enum::LockedVariant;
109 let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
110 let _ = ExperimentalTupleStruct (1); //~ ERROR use of experimental item
111 let _ = UnstableTupleStruct (1); //~ ERROR use of unstable item
112 let _ = UnmarkedTupleStruct (1); //~ ERROR use of unmarked item
113 let _ = StableTupleStruct (1);
114 let _ = FrozenTupleStruct (1);
115 let _ = LockedTupleStruct (1);
117 // At the moment, the lint checker only checks stability in
118 // in the arguments of macros.
119 // Eventually, we will want to lint the contents of the
120 // macro in the module *defining* it. Also, stability levels
121 // on macros themselves are not yet linted.
123 macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item: text
124 macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated item: text
125 macro_test_arg_nested!(deprecated_text);
128 fn test_method_param<F: Trait>(foo: F) {
129 foo.trait_deprecated(); //~ ERROR use of deprecated item
130 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
131 foo.trait_experimental(); //~ ERROR use of experimental item
132 foo.trait_experimental_text(); //~ ERROR use of experimental item: text
133 foo.trait_unstable(); //~ ERROR use of unstable item
134 foo.trait_unstable_text(); //~ ERROR use of unstable item: text
135 foo.trait_unmarked(); //~ ERROR use of unmarked item
139 fn test_method_object(foo: &Trait) {
140 foo.trait_deprecated(); //~ ERROR use of deprecated item
141 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
142 foo.trait_experimental(); //~ ERROR use of experimental item
143 foo.trait_experimental_text(); //~ ERROR use of experimental item: text
144 foo.trait_unstable(); //~ ERROR use of unstable item
145 foo.trait_unstable_text(); //~ ERROR use of unstable item: text
146 foo.trait_unmarked(); //~ ERROR use of unmarked item
152 impl ExperimentalTrait for S { } //~ ERROR use of experimental item
154 trait LocalTrait : ExperimentalTrait { } //~ ERROR use of experimental item
158 extern crate inherited_stability; //~ ERROR: use of experimental item
159 use self::inherited_stability::*;
161 fn test_inheritance() {
162 experimental(); //~ ERROR use of experimental item
165 stable_mod::experimental(); //~ ERROR use of experimental item
166 stable_mod::stable();
168 unstable_mod::experimental(); //~ ERROR use of experimental item
169 unstable_mod::unstable(); //~ ERROR use of unstable item
171 experimental_mod::experimental(); //~ ERROR use of experimental item
172 experimental_mod::stable();
174 let _ = Experimental::ExperimentalVariant; //~ ERROR use of experimental item
175 let _ = Experimental::StableVariant;
178 x.experimental(); //~ ERROR use of experimental item
185 pub fn deprecated() {}
187 pub fn deprecated_text() {}
190 pub fn experimental() {}
191 #[experimental="text"]
192 pub fn experimental_text() {}
197 pub fn unstable_text() {}
204 pub fn stable_text() {}
209 pub fn locked_text() {}
214 pub fn frozen_text() {}
217 pub struct MethodTester;
221 pub fn method_deprecated(&self) {}
223 pub fn method_deprecated_text(&self) {}
226 pub fn method_experimental(&self) {}
227 #[experimental="text"]
228 pub fn method_experimental_text(&self) {}
231 pub fn method_unstable(&self) {}
233 pub fn method_unstable_text(&self) {}
235 pub fn method_unmarked(&self) {}
238 pub fn method_stable(&self) {}
240 pub fn method_stable_text(&self) {}
243 pub fn method_locked(&self) {}
245 pub fn method_locked_text(&self) {}
248 pub fn method_frozen(&self) {}
250 pub fn method_frozen_text(&self) {}
255 fn trait_deprecated(&self) {}
257 fn trait_deprecated_text(&self) {}
260 fn trait_experimental(&self) {}
261 #[experimental="text"]
262 fn trait_experimental_text(&self) {}
265 fn trait_unstable(&self) {}
267 fn trait_unstable_text(&self) {}
269 fn trait_unmarked(&self) {}
272 fn trait_stable(&self) {}
274 fn trait_stable_text(&self) {}
277 fn trait_locked(&self) {}
279 fn trait_locked_text(&self) {}
282 fn trait_frozen(&self) {}
284 fn trait_frozen_text(&self) {}
287 impl Trait for MethodTester {}
290 pub struct DeprecatedStruct { i: int }
292 pub struct ExperimentalStruct { i: int }
294 pub struct UnstableStruct { i: int }
295 pub struct UnmarkedStruct { i: int }
297 pub struct StableStruct { i: int }
299 pub struct FrozenStruct { i: int }
301 pub struct LockedStruct { i: int }
304 pub struct DeprecatedUnitStruct;
306 pub struct ExperimentalUnitStruct;
308 pub struct UnstableUnitStruct;
309 pub struct UnmarkedUnitStruct;
311 pub struct StableUnitStruct;
313 pub struct FrozenUnitStruct;
315 pub struct LockedUnitStruct;
335 pub struct DeprecatedTupleStruct(int);
337 pub struct ExperimentalTupleStruct(int);
339 pub struct UnstableTupleStruct(int);
340 pub struct UnmarkedTupleStruct(int);
342 pub struct StableTupleStruct(int);
344 pub struct FrozenTupleStruct(int);
346 pub struct LockedTupleStruct(int);
349 // Only the deprecated cases of the following should generate
350 // errors, because other stability attributes now have meaning
351 // only *across* crates, not within a single crate.
353 let foo = MethodTester;
355 deprecated(); //~ ERROR use of deprecated item
356 foo.method_deprecated(); //~ ERROR use of deprecated item
357 foo.trait_deprecated(); //~ ERROR use of deprecated item
359 deprecated_text(); //~ ERROR use of deprecated item: text
360 foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
361 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
364 foo.method_experimental();
365 foo.trait_experimental();
368 foo.method_experimental_text();
369 foo.trait_experimental_text();
372 foo.method_unstable();
373 foo.trait_unstable();
376 foo.method_unstable_text();
377 foo.trait_unstable_text();
380 foo.method_unmarked();
381 foo.trait_unmarked();
388 foo.method_stable_text();
389 foo.trait_stable_text();
396 foo.method_frozen_text();
397 foo.trait_frozen_text();
404 foo.method_locked_text();
405 foo.trait_locked_text();
407 let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item
408 let _ = ExperimentalStruct { i: 0 };
409 let _ = UnstableStruct { i: 0 };
410 let _ = UnmarkedStruct { i: 0 };
411 let _ = StableStruct { i: 0 };
412 let _ = FrozenStruct { i: 0 };
413 let _ = LockedStruct { i: 0 };
415 let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
416 let _ = ExperimentalUnitStruct;
417 let _ = UnstableUnitStruct;
418 let _ = UnmarkedUnitStruct;
419 let _ = StableUnitStruct;
420 let _ = FrozenUnitStruct;
421 let _ = LockedUnitStruct;
423 let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
424 let _ = Enum::ExperimentalVariant;
425 let _ = Enum::UnstableVariant;
426 let _ = Enum::UnmarkedVariant;
427 let _ = Enum::StableVariant;
428 let _ = Enum::FrozenVariant;
429 let _ = Enum::LockedVariant;
431 let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
432 let _ = ExperimentalTupleStruct (1);
433 let _ = UnstableTupleStruct (1);
434 let _ = UnmarkedTupleStruct (1);
435 let _ = StableTupleStruct (1);
436 let _ = FrozenTupleStruct (1);
437 let _ = LockedTupleStruct (1);
440 fn test_method_param<F: Trait>(foo: F) {
441 foo.trait_deprecated(); //~ ERROR use of deprecated item
442 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
443 foo.trait_experimental();
444 foo.trait_experimental_text();
445 foo.trait_unstable();
446 foo.trait_unstable_text();
447 foo.trait_unmarked();
451 fn test_method_object(foo: &Trait) {
452 foo.trait_deprecated(); //~ ERROR use of deprecated item
453 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
454 foo.trait_experimental();
455 foo.trait_experimental_text();
456 foo.trait_unstable();
457 foo.trait_unstable_text();
458 foo.trait_unmarked();
470 fn test_method_body(&self) {
477 pub trait DeprecatedTrait {}
481 impl DeprecatedTrait for S { } //~ ERROR use of deprecated item
483 trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item