]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/lint-stability.rs
Imported Upstream version 1.11.0+dfsg1
[rustc.git] / src / test / compile-fail / lint-stability.rs
CommitLineData
1a4d82fc
JJ
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
1a4d82fc 16#![deny(deprecated)]
1a4d82fc 17#![allow(dead_code)]
85aaf69f 18#![feature(staged_api)]
92a42be0
SL
19
20#![stable(feature = "rust1", since = "1.0.0")]
1a4d82fc
JJ
21
22#[macro_use]
85aaf69f 23extern crate lint_stability;
1a4d82fc
JJ
24
25mod cross_crate {
26 extern crate stability_cfg1;
c34b1796 27 extern crate stability_cfg2; //~ ERROR use of unstable library feature
1a4d82fc
JJ
28
29 use lint_stability::*;
30
31 fn test() {
c34b1796 32 type Foo = MethodTester;
1a4d82fc
JJ
33 let foo = MethodTester;
34
35 deprecated(); //~ ERROR use of deprecated item
36 foo.method_deprecated(); //~ ERROR use of deprecated item
c34b1796
AL
37 Foo::method_deprecated(&foo); //~ ERROR use of deprecated item
38 <Foo>::method_deprecated(&foo); //~ ERROR use of deprecated item
1a4d82fc 39 foo.trait_deprecated(); //~ ERROR use of deprecated item
c34b1796
AL
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
1a4d82fc
JJ
43
44 deprecated_text(); //~ ERROR use of deprecated item: text
45 foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
46 Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
47 <Foo>::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
1a4d82fc 48 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
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
1a4d82fc 52
85aaf69f 53 deprecated_unstable(); //~ ERROR use of deprecated item
c34b1796 54 //~^ ERROR use of unstable library feature
85aaf69f 55 foo.method_deprecated_unstable(); //~ ERROR use of deprecated item
c34b1796
AL
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
85aaf69f 61 foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item
c34b1796
AL
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
1a4d82fc 69
85aaf69f 70 deprecated_unstable_text(); //~ ERROR use of deprecated item: text
c34b1796 71 //~^ ERROR use of unstable library feature
85aaf69f 72 foo.method_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
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
85aaf69f 78 foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
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
86
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
1a4d82fc 95
c34b1796
AL
96 unstable_text();
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
1a4d82fc
JJ
112
113 stable();
114 foo.method_stable();
c34b1796
AL
115 Foo::method_stable(&foo);
116 <Foo>::method_stable(&foo);
1a4d82fc 117 foo.trait_stable();
c34b1796
AL
118 Trait::trait_stable(&foo);
119 <Foo>::trait_stable(&foo);
120 <Foo as Trait>::trait_stable(&foo);
1a4d82fc
JJ
121
122 stable_text();
123 foo.method_stable_text();
c34b1796
AL
124 Foo::method_stable_text(&foo);
125 <Foo>::method_stable_text(&foo);
1a4d82fc 126 foo.trait_stable_text();
c34b1796
AL
127 Trait::trait_stable_text(&foo);
128 <Foo>::trait_stable_text(&foo);
129 <Foo as Trait>::trait_stable_text(&foo);
1a4d82fc 130
92a42be0
SL
131 let _ = DeprecatedStruct { //~ ERROR use of deprecated item
132 i: 0 //~ ERROR use of deprecated item
133 };
c1a9b12d
SL
134 let _ = DeprecatedUnstableStruct {
135 //~^ ERROR use of deprecated item
136 //~^^ ERROR use of unstable library feature
137 i: 0 //~ ERROR use of deprecated item
138 };
c34b1796 139 let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable library feature
1a4d82fc 140 let _ = StableStruct { i: 0 };
1a4d82fc
JJ
141
142 let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
85aaf69f 143 let _ = DeprecatedUnstableUnitStruct; //~ ERROR use of deprecated item
c34b1796
AL
144 //~^ ERROR use of unstable library feature
145 let _ = UnstableUnitStruct; //~ ERROR use of unstable library feature
1a4d82fc 146 let _ = StableUnitStruct;
1a4d82fc
JJ
147
148 let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
85aaf69f 149 let _ = Enum::DeprecatedUnstableVariant; //~ ERROR use of deprecated item
c34b1796
AL
150 //~^ ERROR use of unstable library feature
151 let _ = Enum::UnstableVariant; //~ ERROR use of unstable library feature
1a4d82fc 152 let _ = Enum::StableVariant;
1a4d82fc
JJ
153
154 let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
85aaf69f 155 let _ = DeprecatedUnstableTupleStruct (1); //~ ERROR use of deprecated item
c34b1796
AL
156 //~^ ERROR use of unstable library feature
157 let _ = UnstableTupleStruct (1); //~ ERROR use of unstable library feature
1a4d82fc 158 let _ = StableTupleStruct (1);
1a4d82fc
JJ
159
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.
1a4d82fc 165 macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item: text
85aaf69f 166 macro_test_arg!(deprecated_unstable_text()); //~ ERROR use of deprecated item: text
c34b1796 167 //~^ ERROR use of unstable library feature
1a4d82fc 168 macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated item: text
1a4d82fc
JJ
169 }
170
c34b1796 171 fn test_method_param<Foo: Trait>(foo: Foo) {
1a4d82fc 172 foo.trait_deprecated(); //~ ERROR use of deprecated item
c34b1796
AL
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
1a4d82fc 176 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
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
85aaf69f 180 foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item
c34b1796
AL
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
85aaf69f 188 foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
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
1a4d82fc 208 foo.trait_stable();
c34b1796
AL
209 Trait::trait_stable(&foo);
210 <Foo>::trait_stable(&foo);
211 <Foo as Trait>::trait_stable(&foo);
1a4d82fc
JJ
212 }
213
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
85aaf69f 217 foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item
c34b1796 218 //~^ ERROR use of unstable library feature
85aaf69f 219 foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
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
1a4d82fc
JJ
224 foo.trait_stable();
225 }
226
227 struct S;
228
c34b1796 229 impl UnstableTrait for S { } //~ ERROR use of unstable library feature
9cc50fc6 230 impl DeprecatedTrait for S {} //~ ERROR use of deprecated item: text
c34b1796 231 trait LocalTrait : UnstableTrait { } //~ ERROR use of unstable library feature
9cc50fc6 232 trait LocalTrait2 : DeprecatedTrait { } //~ ERROR use of deprecated item: text
1a4d82fc 233
85aaf69f
SL
234 impl Trait for S {
235 fn trait_stable(&self) {}
c34b1796 236 fn trait_unstable(&self) {} //~ ERROR use of unstable library feature
85aaf69f 237 }
1a4d82fc
JJ
238}
239
240mod inheritance {
c34b1796
AL
241 extern crate inherited_stability; //~ ERROR use of unstable library feature
242 use self::inherited_stability::*; //~ ERROR use of unstable library feature
1a4d82fc
JJ
243
244 fn test_inheritance() {
c34b1796 245 unstable(); //~ ERROR use of unstable library feature
1a4d82fc
JJ
246 stable();
247
c34b1796 248 stable_mod::unstable(); //~ ERROR use of unstable library feature
1a4d82fc
JJ
249 stable_mod::stable();
250
85aaf69f 251 unstable_mod::deprecated(); //~ ERROR use of deprecated item
c34b1796 252 unstable_mod::unstable(); //~ ERROR use of unstable library feature
1a4d82fc 253
c34b1796 254 let _ = Unstable::UnstableVariant; //~ ERROR use of unstable library feature
85aaf69f 255 let _ = Unstable::StableVariant;
1a4d82fc
JJ
256
257 let x: usize = 0;
c34b1796 258 x.unstable(); //~ ERROR use of unstable library feature
1a4d82fc
JJ
259 x.stable();
260 }
261}
262
263mod this_crate {
e9174d1e 264 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 265 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc 266 pub fn deprecated() {}
e9174d1e 267 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 268 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc
JJ
269 pub fn deprecated_text() {}
270
e9174d1e 271 #[unstable(feature = "test_feature", issue = "0")]
1a4d82fc 272 pub fn unstable() {}
e9174d1e 273 #[unstable(feature = "test_feature", reason = "text", issue = "0")]
1a4d82fc
JJ
274 pub fn unstable_text() {}
275
85aaf69f 276 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 277 pub fn stable() {}
b039eaaf 278 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc
JJ
279 pub fn stable_text() {}
280
85aaf69f 281 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc
JJ
282 pub struct MethodTester;
283
284 impl MethodTester {
e9174d1e 285 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 286 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc 287 pub fn method_deprecated(&self) {}
e9174d1e 288 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 289 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc
JJ
290 pub fn method_deprecated_text(&self) {}
291
e9174d1e 292 #[unstable(feature = "test_feature", issue = "0")]
1a4d82fc 293 pub fn method_unstable(&self) {}
e9174d1e 294 #[unstable(feature = "test_feature", reason = "text", issue = "0")]
1a4d82fc
JJ
295 pub fn method_unstable_text(&self) {}
296
85aaf69f 297 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 298 pub fn method_stable(&self) {}
b039eaaf 299 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 300 pub fn method_stable_text(&self) {}
1a4d82fc
JJ
301 }
302
303 pub trait Trait {
e9174d1e 304 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 305 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc 306 fn trait_deprecated(&self) {}
e9174d1e 307 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 308 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc
JJ
309 fn trait_deprecated_text(&self) {}
310
e9174d1e 311 #[unstable(feature = "test_feature", issue = "0")]
1a4d82fc 312 fn trait_unstable(&self) {}
e9174d1e 313 #[unstable(feature = "test_feature", reason = "text", issue = "0")]
1a4d82fc
JJ
314 fn trait_unstable_text(&self) {}
315
85aaf69f 316 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 317 fn trait_stable(&self) {}
b039eaaf 318 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 319 fn trait_stable_text(&self) {}
1a4d82fc
JJ
320 }
321
322 impl Trait for MethodTester {}
323
e9174d1e 324 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 325 #[rustc_deprecated(since = "1.0.0", reason = "text")]
c34b1796
AL
326 pub struct DeprecatedStruct {
327 #[stable(feature = "test_feature", since = "1.0.0")] i: isize
328 }
e9174d1e 329 #[unstable(feature = "test_feature", issue = "0")]
c34b1796
AL
330 pub struct UnstableStruct {
331 #[stable(feature = "test_feature", since = "1.0.0")] i: isize
332 }
85aaf69f 333 #[stable(feature = "rust1", since = "1.0.0")]
c34b1796
AL
334 pub struct StableStruct {
335 #[stable(feature = "test_feature", since = "1.0.0")] i: isize
336 }
1a4d82fc 337
e9174d1e 338 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 339 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc 340 pub struct DeprecatedUnitStruct;
e9174d1e 341 #[unstable(feature = "test_feature", issue = "0")]
1a4d82fc 342 pub struct UnstableUnitStruct;
85aaf69f 343 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 344 pub struct StableUnitStruct;
1a4d82fc
JJ
345
346 pub enum Enum {
e9174d1e 347 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 348 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc 349 DeprecatedVariant,
e9174d1e 350 #[unstable(feature = "test_feature", issue = "0")]
1a4d82fc
JJ
351 UnstableVariant,
352
85aaf69f 353 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 354 StableVariant,
1a4d82fc
JJ
355 }
356
e9174d1e 357 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 358 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc 359 pub struct DeprecatedTupleStruct(isize);
e9174d1e 360 #[unstable(feature = "test_feature", issue = "0")]
1a4d82fc 361 pub struct UnstableTupleStruct(isize);
85aaf69f 362 #[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 363 pub struct StableTupleStruct(isize);
1a4d82fc
JJ
364
365 fn test() {
366 // Only the deprecated cases of the following should generate
367 // errors, because other stability attributes now have meaning
368 // only *across* crates, not within a single crate.
369
c34b1796 370 type Foo = MethodTester;
1a4d82fc
JJ
371 let foo = MethodTester;
372
373 deprecated(); //~ ERROR use of deprecated item
374 foo.method_deprecated(); //~ ERROR use of deprecated item
c34b1796
AL
375 Foo::method_deprecated(&foo); //~ ERROR use of deprecated item
376 <Foo>::method_deprecated(&foo); //~ ERROR use of deprecated item
1a4d82fc 377 foo.trait_deprecated(); //~ ERROR use of deprecated item
c34b1796
AL
378 Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
379 <Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
380 <Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
1a4d82fc
JJ
381
382 deprecated_text(); //~ ERROR use of deprecated item: text
383 foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
384 Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
385 <Foo>::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
1a4d82fc 386 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
387 Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
388 <Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
389 <Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
1a4d82fc 390
1a4d82fc
JJ
391 unstable();
392 foo.method_unstable();
c34b1796
AL
393 Foo::method_unstable(&foo);
394 <Foo>::method_unstable(&foo);
1a4d82fc 395 foo.trait_unstable();
c34b1796
AL
396 Trait::trait_unstable(&foo);
397 <Foo>::trait_unstable(&foo);
398 <Foo as Trait>::trait_unstable(&foo);
1a4d82fc
JJ
399
400 unstable_text();
401 foo.method_unstable_text();
c34b1796
AL
402 Foo::method_unstable_text(&foo);
403 <Foo>::method_unstable_text(&foo);
1a4d82fc 404 foo.trait_unstable_text();
c34b1796
AL
405 Trait::trait_unstable_text(&foo);
406 <Foo>::trait_unstable_text(&foo);
407 <Foo as Trait>::trait_unstable_text(&foo);
1a4d82fc 408
1a4d82fc
JJ
409 stable();
410 foo.method_stable();
c34b1796
AL
411 Foo::method_stable(&foo);
412 <Foo>::method_stable(&foo);
1a4d82fc 413 foo.trait_stable();
c34b1796
AL
414 Trait::trait_stable(&foo);
415 <Foo>::trait_stable(&foo);
416 <Foo as Trait>::trait_stable(&foo);
1a4d82fc
JJ
417
418 stable_text();
419 foo.method_stable_text();
c34b1796
AL
420 Foo::method_stable_text(&foo);
421 <Foo>::method_stable_text(&foo);
1a4d82fc 422 foo.trait_stable_text();
c34b1796
AL
423 Trait::trait_stable_text(&foo);
424 <Foo>::trait_stable_text(&foo);
425 <Foo as Trait>::trait_stable_text(&foo);
1a4d82fc 426
c1a9b12d
SL
427 let _ = DeprecatedStruct {
428 //~^ ERROR use of deprecated item
429 i: 0 //~ ERROR use of deprecated item
430 };
1a4d82fc 431 let _ = UnstableStruct { i: 0 };
1a4d82fc 432 let _ = StableStruct { i: 0 };
1a4d82fc
JJ
433
434 let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
1a4d82fc 435 let _ = UnstableUnitStruct;
1a4d82fc 436 let _ = StableUnitStruct;
1a4d82fc
JJ
437
438 let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
1a4d82fc 439 let _ = Enum::UnstableVariant;
1a4d82fc 440 let _ = Enum::StableVariant;
1a4d82fc
JJ
441
442 let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
1a4d82fc 443 let _ = UnstableTupleStruct (1);
1a4d82fc 444 let _ = StableTupleStruct (1);
1a4d82fc
JJ
445 }
446
c34b1796 447 fn test_method_param<Foo: Trait>(foo: Foo) {
1a4d82fc 448 foo.trait_deprecated(); //~ ERROR use of deprecated item
c34b1796
AL
449 Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
450 <Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
451 <Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
1a4d82fc 452 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
c34b1796
AL
453 Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
454 <Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
455 <Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
1a4d82fc 456 foo.trait_unstable();
c34b1796
AL
457 Trait::trait_unstable(&foo);
458 <Foo>::trait_unstable(&foo);
459 <Foo as Trait>::trait_unstable(&foo);
1a4d82fc 460 foo.trait_unstable_text();
c34b1796
AL
461 Trait::trait_unstable_text(&foo);
462 <Foo>::trait_unstable_text(&foo);
463 <Foo as Trait>::trait_unstable_text(&foo);
1a4d82fc 464 foo.trait_stable();
c34b1796
AL
465 Trait::trait_stable(&foo);
466 <Foo>::trait_stable(&foo);
467 <Foo as Trait>::trait_stable(&foo);
1a4d82fc
JJ
468 }
469
470 fn test_method_object(foo: &Trait) {
471 foo.trait_deprecated(); //~ ERROR use of deprecated item
472 foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
1a4d82fc
JJ
473 foo.trait_unstable();
474 foo.trait_unstable_text();
1a4d82fc
JJ
475 foo.trait_stable();
476 }
477
e9174d1e 478 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 479 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc
JJ
480 fn test_fn_body() {
481 fn fn_in_body() {}
92a42be0 482 fn_in_body(); //~ ERROR use of deprecated item: text
1a4d82fc
JJ
483 }
484
485 impl MethodTester {
e9174d1e 486 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 487 #[rustc_deprecated(since = "1.0.0", reason = "text")]
1a4d82fc
JJ
488 fn test_method_body(&self) {
489 fn fn_in_body() {}
92a42be0 490 fn_in_body(); //~ ERROR use of deprecated item: text
1a4d82fc
JJ
491 }
492 }
493
e9174d1e 494 #[unstable(feature = "test_feature", issue = "0")]
92a42be0 495 #[rustc_deprecated(since = "1.0.0", reason = "text")]
85aaf69f
SL
496 pub trait DeprecatedTrait {
497 fn dummy(&self) { }
498 }
1a4d82fc
JJ
499
500 struct S;
501
502 impl DeprecatedTrait for S { } //~ ERROR use of deprecated item
503
504 trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item
505}
506
507fn main() {}