]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/lint-stability-deprecated.rs
Move parse-fail tests to UI
[rust.git] / src / test / ui / lint / lint-stability-deprecated.rs
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.
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.rs
12 // aux-build:inherited_stability.rs
13 // aux-build:stability_cfg1.rs
14 // aux-build:stability_cfg2.rs
15 // ignore-tidy-linelength
16
17 #![warn(deprecated)]
18 #![allow(dead_code, unused_extern_crates)]
19 #![feature(staged_api, unstable_test_feature, rustc_attrs)]
20
21 #![stable(feature = "rust1", since = "1.0.0")]
22
23 #[macro_use]
24 extern crate lint_stability;
25
26 mod cross_crate {
27     extern crate stability_cfg1;
28     extern crate stability_cfg2;
29
30     use lint_stability::*;
31
32     fn test() {
33         type Foo = MethodTester;
34         let foo = MethodTester;
35
36         deprecated(); //~ WARN use of deprecated item 'lint_stability::deprecated'
37         foo.method_deprecated(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated'
38         Foo::method_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated'
39         <Foo>::method_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated'
40         foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated'
41         Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated'
42         <Foo>::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated'
43         <Foo as Trait>::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated'
44
45         deprecated_text(); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text
46         foo.method_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text
47         Foo::method_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text
48         <Foo>::method_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text
49         foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text
50         Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text
51         <Foo>::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text
52         <Foo as Trait>::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text
53
54         deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable'
55         foo.method_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable'
56         Foo::method_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable'
57         <Foo>::method_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable'
58         foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable'
59         Trait::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable'
60         <Foo>::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable'
61         <Foo as Trait>::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable'
62
63         deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable_text': text
64         foo.method_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text
65         Foo::method_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text
66         <Foo>::method_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text
67         foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
68         Trait::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
69         <Foo>::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
70         <Foo as Trait>::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
71
72         unstable();
73         foo.method_unstable();
74         Foo::method_unstable(&foo);
75         <Foo>::method_unstable(&foo);
76         foo.trait_unstable();
77         Trait::trait_unstable(&foo);
78         <Foo>::trait_unstable(&foo);
79         <Foo as Trait>::trait_unstable(&foo);
80
81         unstable_text();
82         foo.method_unstable_text();
83         Foo::method_unstable_text(&foo);
84         <Foo>::method_unstable_text(&foo);
85         foo.trait_unstable_text();
86         Trait::trait_unstable_text(&foo);
87         <Foo>::trait_unstable_text(&foo);
88         <Foo as Trait>::trait_unstable_text(&foo);
89
90         stable();
91         foo.method_stable();
92         Foo::method_stable(&foo);
93         <Foo>::method_stable(&foo);
94         foo.trait_stable();
95         Trait::trait_stable(&foo);
96         <Foo>::trait_stable(&foo);
97         <Foo as Trait>::trait_stable(&foo);
98
99         stable_text();
100         foo.method_stable_text();
101         Foo::method_stable_text(&foo);
102         <Foo>::method_stable_text(&foo);
103         foo.trait_stable_text();
104         Trait::trait_stable_text(&foo);
105         <Foo>::trait_stable_text(&foo);
106         <Foo as Trait>::trait_stable_text(&foo);
107
108         struct S1<T: TraitWithAssociatedTypes>(T::TypeUnstable);
109         struct S2<T: TraitWithAssociatedTypes>(T::TypeDeprecated);
110         //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated': text
111         type A = TraitWithAssociatedTypes<
112             TypeUnstable = u8,
113             TypeDeprecated = u16,
114             //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated'
115         >;
116
117         let _ = DeprecatedStruct { //~ WARN use of deprecated item 'lint_stability::DeprecatedStruct'
118             i: 0 //~ WARN use of deprecated item 'lint_stability::DeprecatedStruct::i'
119         };
120         let _ = DeprecatedUnstableStruct {
121             //~^ WARN use of deprecated item 'lint_stability::DeprecatedUnstableStruct'
122             i: 0 //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableStruct::i'
123         };
124         let _ = UnstableStruct { i: 0 };
125         let _ = StableStruct { i: 0 };
126
127         let _ = DeprecatedUnitStruct; //~ WARN use of deprecated item 'lint_stability::DeprecatedUnitStruct'
128         let _ = DeprecatedUnstableUnitStruct; //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableUnitStruct'
129         let _ = UnstableUnitStruct;
130         let _ = StableUnitStruct;
131
132         let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated item 'lint_stability::Enum::DeprecatedVariant'
133         let _ = Enum::DeprecatedUnstableVariant; //~ WARN use of deprecated item 'lint_stability::Enum::DeprecatedUnstableVariant'
134         let _ = Enum::UnstableVariant;
135         let _ = Enum::StableVariant;
136
137         let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated item 'lint_stability::DeprecatedTupleStruct'
138         let _ = DeprecatedUnstableTupleStruct (1); //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableTupleStruct'
139         let _ = UnstableTupleStruct (1);
140         let _ = StableTupleStruct (1);
141
142         // At the moment, the lint checker only checks stability in
143         // in the arguments of macros.
144         // Eventually, we will want to lint the contents of the
145         // macro in the module *defining* it. Also, stability levels
146         // on macros themselves are not yet linted.
147         macro_test_arg!(deprecated_text()); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text
148         macro_test_arg!(deprecated_unstable_text()); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable_text': text
149         macro_test_arg!(macro_test_arg!(deprecated_text())); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text
150     }
151
152     fn test_method_param<Foo: Trait>(foo: Foo) {
153         foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated'
154         Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated'
155         <Foo>::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated'
156         <Foo as Trait>::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated'
157         foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text
158         Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text
159         <Foo>::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text
160         <Foo as Trait>::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text
161         foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable'
162         Trait::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable'
163         <Foo>::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable'
164         <Foo as Trait>::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable'
165         foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
166         Trait::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
167         <Foo>::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
168         <Foo as Trait>::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
169         foo.trait_unstable();
170         Trait::trait_unstable(&foo);
171         <Foo>::trait_unstable(&foo);
172         <Foo as Trait>::trait_unstable(&foo);
173         foo.trait_unstable_text();
174         Trait::trait_unstable_text(&foo);
175         <Foo>::trait_unstable_text(&foo);
176         <Foo as Trait>::trait_unstable_text(&foo);
177         foo.trait_stable();
178         Trait::trait_stable(&foo);
179         <Foo>::trait_stable(&foo);
180         <Foo as Trait>::trait_stable(&foo);
181     }
182
183     fn test_method_object(foo: &Trait) {
184         foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated'
185         foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text
186         foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable'
187         foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
188         foo.trait_unstable();
189         foo.trait_unstable_text();
190         foo.trait_stable();
191     }
192
193     struct S;
194
195     impl UnstableTrait for S { }
196     impl DeprecatedTrait for S {} //~ WARN use of deprecated item 'lint_stability::DeprecatedTrait': text
197     trait LocalTrait : UnstableTrait { }
198     trait LocalTrait2 : DeprecatedTrait { } //~ WARN use of deprecated item 'lint_stability::DeprecatedTrait': text
199
200     impl Trait for S {
201         fn trait_stable(&self) {}
202         fn trait_unstable(&self) {}
203     }
204 }
205
206 mod inheritance {
207     extern crate inherited_stability;
208     use self::inherited_stability::*;
209
210     fn test_inheritance() {
211         unstable();
212         stable();
213
214         stable_mod::unstable();
215         stable_mod::stable();
216
217         unstable_mod::deprecated(); //~ WARN use of deprecated item 'inheritance::inherited_stability::unstable_mod::deprecated': text
218         unstable_mod::unstable();
219
220         let _ = Unstable::UnstableVariant;
221         let _ = Unstable::StableVariant;
222
223         let x: usize = 0;
224         x.unstable();
225         x.stable();
226     }
227 }
228
229 mod this_crate {
230     #[unstable(feature = "unstable_test_feature", issue = "0")]
231     #[rustc_deprecated(since = "1.0.0", reason = "text")]
232     pub fn deprecated() {}
233     #[unstable(feature = "unstable_test_feature", issue = "0")]
234     #[rustc_deprecated(since = "1.0.0", reason = "text")]
235     pub fn deprecated_text() {}
236
237     #[unstable(feature = "unstable_test_feature", issue = "0")]
238     pub fn unstable() {}
239     #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")]
240     pub fn unstable_text() {}
241
242     #[stable(feature = "rust1", since = "1.0.0")]
243     pub fn stable() {}
244     #[stable(feature = "rust1", since = "1.0.0")]
245     pub fn stable_text() {}
246
247     #[stable(feature = "rust1", since = "1.0.0")]
248     pub struct MethodTester;
249
250     impl MethodTester {
251         #[unstable(feature = "unstable_test_feature", issue = "0")]
252         #[rustc_deprecated(since = "1.0.0", reason = "text")]
253         pub fn method_deprecated(&self) {}
254         #[unstable(feature = "unstable_test_feature", issue = "0")]
255         #[rustc_deprecated(since = "1.0.0", reason = "text")]
256         pub fn method_deprecated_text(&self) {}
257
258         #[unstable(feature = "unstable_test_feature", issue = "0")]
259         pub fn method_unstable(&self) {}
260         #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")]
261         pub fn method_unstable_text(&self) {}
262
263         #[stable(feature = "rust1", since = "1.0.0")]
264         pub fn method_stable(&self) {}
265         #[stable(feature = "rust1", since = "1.0.0")]
266         pub fn method_stable_text(&self) {}
267     }
268
269     pub trait Trait {
270         #[unstable(feature = "unstable_test_feature", issue = "0")]
271         #[rustc_deprecated(since = "1.0.0", reason = "text")]
272         fn trait_deprecated(&self) {}
273         #[unstable(feature = "unstable_test_feature", issue = "0")]
274         #[rustc_deprecated(since = "1.0.0", reason = "text")]
275         fn trait_deprecated_text(&self) {}
276
277         #[unstable(feature = "unstable_test_feature", issue = "0")]
278         fn trait_unstable(&self) {}
279         #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")]
280         fn trait_unstable_text(&self) {}
281
282         #[stable(feature = "rust1", since = "1.0.0")]
283         fn trait_stable(&self) {}
284         #[stable(feature = "rust1", since = "1.0.0")]
285         fn trait_stable_text(&self) {}
286     }
287
288     impl Trait for MethodTester {}
289
290     #[unstable(feature = "unstable_test_feature", issue = "0")]
291     #[rustc_deprecated(since = "1.0.0", reason = "text")]
292     pub struct DeprecatedStruct {
293         #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize
294     }
295     #[unstable(feature = "unstable_test_feature", issue = "0")]
296     pub struct UnstableStruct {
297         #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize
298     }
299     #[stable(feature = "rust1", since = "1.0.0")]
300     pub struct StableStruct {
301         #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize
302     }
303
304     #[unstable(feature = "unstable_test_feature", issue = "0")]
305     #[rustc_deprecated(since = "1.0.0", reason = "text")]
306     pub struct DeprecatedUnitStruct;
307     #[unstable(feature = "unstable_test_feature", issue = "0")]
308     pub struct UnstableUnitStruct;
309     #[stable(feature = "rust1", since = "1.0.0")]
310     pub struct StableUnitStruct;
311
312     pub enum Enum {
313         #[unstable(feature = "unstable_test_feature", issue = "0")]
314         #[rustc_deprecated(since = "1.0.0", reason = "text")]
315         DeprecatedVariant,
316         #[unstable(feature = "unstable_test_feature", issue = "0")]
317         UnstableVariant,
318
319         #[stable(feature = "rust1", since = "1.0.0")]
320         StableVariant,
321     }
322
323     #[unstable(feature = "unstable_test_feature", issue = "0")]
324     #[rustc_deprecated(since = "1.0.0", reason = "text")]
325     pub struct DeprecatedTupleStruct(isize);
326     #[unstable(feature = "unstable_test_feature", issue = "0")]
327     pub struct UnstableTupleStruct(isize);
328     #[stable(feature = "rust1", since = "1.0.0")]
329     pub struct StableTupleStruct(isize);
330
331     fn test() {
332         // Only the deprecated cases of the following should generate
333         // errors, because other stability attributes now have meaning
334         // only *across* crates, not within a single crate.
335
336         type Foo = MethodTester;
337         let foo = MethodTester;
338
339         deprecated(); //~ WARN use of deprecated item 'this_crate::deprecated'
340         foo.method_deprecated(); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated'
341         Foo::method_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated'
342         <Foo>::method_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated'
343         foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated'
344         Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated'
345         <Foo>::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated'
346         <Foo as Trait>::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated'
347
348         deprecated_text(); //~ WARN use of deprecated item 'this_crate::deprecated_text': text
349         foo.method_deprecated_text(); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text
350         Foo::method_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text
351         <Foo>::method_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text
352         foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
353         Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
354         <Foo>::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
355         <Foo as Trait>::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
356
357         unstable();
358         foo.method_unstable();
359         Foo::method_unstable(&foo);
360         <Foo>::method_unstable(&foo);
361         foo.trait_unstable();
362         Trait::trait_unstable(&foo);
363         <Foo>::trait_unstable(&foo);
364         <Foo as Trait>::trait_unstable(&foo);
365
366         unstable_text();
367         foo.method_unstable_text();
368         Foo::method_unstable_text(&foo);
369         <Foo>::method_unstable_text(&foo);
370         foo.trait_unstable_text();
371         Trait::trait_unstable_text(&foo);
372         <Foo>::trait_unstable_text(&foo);
373         <Foo as Trait>::trait_unstable_text(&foo);
374
375         stable();
376         foo.method_stable();
377         Foo::method_stable(&foo);
378         <Foo>::method_stable(&foo);
379         foo.trait_stable();
380         Trait::trait_stable(&foo);
381         <Foo>::trait_stable(&foo);
382         <Foo as Trait>::trait_stable(&foo);
383
384         stable_text();
385         foo.method_stable_text();
386         Foo::method_stable_text(&foo);
387         <Foo>::method_stable_text(&foo);
388         foo.trait_stable_text();
389         Trait::trait_stable_text(&foo);
390         <Foo>::trait_stable_text(&foo);
391         <Foo as Trait>::trait_stable_text(&foo);
392
393         let _ = DeprecatedStruct {
394             //~^ WARN use of deprecated item 'this_crate::DeprecatedStruct'
395             i: 0 //~ WARN use of deprecated item 'this_crate::DeprecatedStruct::i'
396         };
397         let _ = UnstableStruct { i: 0 };
398         let _ = StableStruct { i: 0 };
399
400         let _ = DeprecatedUnitStruct; //~ WARN use of deprecated item 'this_crate::DeprecatedUnitStruct'
401         let _ = UnstableUnitStruct;
402         let _ = StableUnitStruct;
403
404         let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated item 'this_crate::Enum::DeprecatedVariant'
405         let _ = Enum::UnstableVariant;
406         let _ = Enum::StableVariant;
407
408         let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated item 'this_crate::DeprecatedTupleStruct'
409         let _ = UnstableTupleStruct (1);
410         let _ = StableTupleStruct (1);
411     }
412
413     fn test_method_param<Foo: Trait>(foo: Foo) {
414         foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated'
415         Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated'
416         <Foo>::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated'
417         <Foo as Trait>::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated'
418         foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
419         Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
420         <Foo>::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
421         <Foo as Trait>::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
422         foo.trait_unstable();
423         Trait::trait_unstable(&foo);
424         <Foo>::trait_unstable(&foo);
425         <Foo as Trait>::trait_unstable(&foo);
426         foo.trait_unstable_text();
427         Trait::trait_unstable_text(&foo);
428         <Foo>::trait_unstable_text(&foo);
429         <Foo as Trait>::trait_unstable_text(&foo);
430         foo.trait_stable();
431         Trait::trait_stable(&foo);
432         <Foo>::trait_stable(&foo);
433         <Foo as Trait>::trait_stable(&foo);
434     }
435
436     fn test_method_object(foo: &Trait) {
437         foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated'
438         foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text
439         foo.trait_unstable();
440         foo.trait_unstable_text();
441         foo.trait_stable();
442     }
443
444     #[unstable(feature = "unstable_test_feature", issue = "0")]
445     #[rustc_deprecated(since = "1.0.0", reason = "text")]
446     fn test_fn_body() {
447         fn fn_in_body() {}
448         fn_in_body(); //~ WARN use of deprecated item 'this_crate::test_fn_body::fn_in_body': text
449     }
450
451     impl MethodTester {
452         #[unstable(feature = "unstable_test_feature", issue = "0")]
453         #[rustc_deprecated(since = "1.0.0", reason = "text")]
454         fn test_method_body(&self) {
455             fn fn_in_body() {}
456             fn_in_body(); //~ WARN use of deprecated item 'this_crate::MethodTester::test_method_body::fn_in_body': text
457         }
458     }
459
460     #[unstable(feature = "unstable_test_feature", issue = "0")]
461     #[rustc_deprecated(since = "1.0.0", reason = "text")]
462     pub trait DeprecatedTrait {
463         fn dummy(&self) { }
464     }
465
466     struct S;
467
468     impl DeprecatedTrait for S { } //~ WARN use of deprecated item 'this_crate::DeprecatedTrait'
469
470     trait LocalTrait : DeprecatedTrait { } //~ WARN use of deprecated item 'this_crate::DeprecatedTrait'
471 }
472
473 #[rustc_error] fn main() {} //~ ERROR: compilation successful