]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/deprecation/deprecation-lint.rs
1 // aux-build:deprecation-lint.rs
2 // ignore-tidy-linelength
8 extern crate deprecation_lint
;
11 use deprecation_lint
::*;
14 type Foo
= MethodTester
;
15 let foo
= MethodTester
;
17 deprecated(); //~ ERROR use of deprecated function `deprecation_lint::deprecated`
18 foo
.method_deprecated(); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated`
19 Foo
::method_deprecated(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated`
20 <Foo
>::method_deprecated(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated`
21 foo
.trait_deprecated(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`
22 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`
23 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`
24 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`
26 deprecated_text(); //~ ERROR use of deprecated function `deprecation_lint::deprecated_text`: text
27 foo
.method_deprecated_text(); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text
28 Foo
::method_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text
29 <Foo
>::method_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text
30 foo
.trait_deprecated_text(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
31 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
32 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
33 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
35 let _
= DeprecatedStruct
{ //~ ERROR use of deprecated struct `deprecation_lint::DeprecatedStruct`: text
36 i
: 0 //~ ERROR use of deprecated field `deprecation_lint::DeprecatedStruct::i`: text
39 let _
= DeprecatedUnitStruct
; //~ ERROR use of deprecated struct `deprecation_lint::DeprecatedUnitStruct`: text
41 let _
= Enum
::DeprecatedVariant
; //~ ERROR use of deprecated variant `deprecation_lint::Enum::DeprecatedVariant`: text
43 let _
= DeprecatedTupleStruct (1); //~ ERROR use of deprecated struct `deprecation_lint::DeprecatedTupleStruct`: text
45 let _
= nested
::DeprecatedStruct
{ //~ ERROR use of deprecated struct `deprecation_lint::nested::DeprecatedStruct`: text
46 i
: 0 //~ ERROR use of deprecated field `deprecation_lint::nested::DeprecatedStruct::i`: text
49 let _
= nested
::DeprecatedUnitStruct
; //~ ERROR use of deprecated struct `deprecation_lint::nested::DeprecatedUnitStruct`: text
51 let _
= nested
::Enum
::DeprecatedVariant
; //~ ERROR use of deprecated variant `deprecation_lint::nested::Enum::DeprecatedVariant`: text
53 let _
= nested
::DeprecatedTupleStruct (1); //~ ERROR use of deprecated struct `deprecation_lint::nested::DeprecatedTupleStruct`: text
55 // At the moment, the lint checker only checks stability in
56 // in the arguments of macros.
57 // Eventually, we will want to lint the contents of the
58 // macro in the module *defining* it. Also, stability levels
59 // on macros themselves are not yet linted.
60 macro_test_arg
!(deprecated_text()); //~ ERROR use of deprecated function `deprecation_lint::deprecated_text`: text
61 macro_test_arg
!(macro_test_arg
!(deprecated_text())); //~ ERROR use of deprecated function `deprecation_lint::deprecated_text`: text
64 fn test_method_param
<Foo
: Trait
>(foo
: Foo
) {
65 foo
.trait_deprecated(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`
66 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`
67 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`
68 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`
69 foo
.trait_deprecated_text(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
70 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
71 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
72 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
75 fn test_method_object(foo
: &Trait
) {
76 foo
.trait_deprecated(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`
77 foo
.trait_deprecated_text(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
82 impl DeprecatedTrait
for S {}
//~ ERROR use of deprecated trait `deprecation_lint::DeprecatedTrait`: text
83 trait LocalTrait
: DeprecatedTrait { }
//~ ERROR use of deprecated trait `deprecation_lint::DeprecatedTrait`: text
88 //~^ ERROR use of deprecated field `deprecation_lint::Stable::override2`: text
92 //~^ ERROR use of deprecated field `deprecation_lint::Stable::override2`: text
96 //~^ ERROR use of deprecated field `deprecation_lint::Stable::override2`: text
99 let Stable { .. }
= x
;
101 let x
= Stable2(1, 2, 3);
104 //~^ ERROR use of deprecated field `deprecation_lint::Stable2::2`: text
109 //~^ ERROR use of deprecated field `deprecation_lint::Stable2::2`: text
115 //~^ ERROR use of deprecated struct `deprecation_lint::Deprecated`: text
117 //~^ ERROR use of deprecated field `deprecation_lint::Deprecated::inherit`: text
121 //~^ ERROR use of deprecated field `deprecation_lint::Deprecated::inherit`: text
124 //~^ ERROR use of deprecated struct `deprecation_lint::Deprecated`: text
126 //~^ ERROR use of deprecated field `deprecation_lint::Deprecated::inherit`: text
130 //~^ ERROR use of deprecated struct `deprecation_lint::Deprecated`: text
133 let x
= Deprecated2(1, 2, 3);
134 //~^ ERROR use of deprecated struct `deprecation_lint::Deprecated2`: text
137 //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::0`: text
139 //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::1`: text
141 //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::2`: text
144 //~^ ERROR use of deprecated struct `deprecation_lint::Deprecated2`: text
146 //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::0`: text
148 //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::1`: text
150 //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::2`: text
153 //~^ ERROR use of deprecated struct `deprecation_lint::Deprecated2`: text
154 // the patterns are all fine:
160 use deprecation_lint
::*;
162 fn test_inheritance() {
163 deprecated_mod
::deprecated(); //~ ERROR use of deprecated function `deprecation_lint::deprecated_mod::deprecated`: text
168 #[deprecated(since = "1.0.0", note = "text")]
169 pub fn deprecated() {}
170 #[deprecated(since = "1.0.0", note = "text")]
171 pub fn deprecated_text() {}
173 #[deprecated(since = "99.99.99", note = "text")]
174 pub fn deprecated_future() {}
175 #[deprecated(since = "99.99.99", note = "text")]
176 pub fn deprecated_future_text() {}
178 pub struct MethodTester
;
181 #[deprecated(since = "1.0.0", note = "text")]
182 pub fn method_deprecated(&self) {}
183 #[deprecated(since = "1.0.0", note = "text")]
184 pub fn method_deprecated_text(&self) {}
188 #[deprecated(since = "1.0.0", note = "text")]
189 fn trait_deprecated(&self) {}
190 #[deprecated(since = "1.0.0", note = "text")]
191 fn trait_deprecated_text(&self) {}
194 impl Trait
for MethodTester {}
196 #[deprecated(since = "1.0.0", note = "text")]
197 pub struct DeprecatedStruct
{
200 pub struct UnstableStruct
{
203 pub struct StableStruct
{
207 #[deprecated(since = "1.0.0", note = "text")]
208 pub struct DeprecatedUnitStruct
;
211 #[deprecated(since = "1.0.0", note = "text")]
215 #[deprecated(since = "1.0.0", note = "text")]
216 pub struct DeprecatedTupleStruct(isize);
219 #[deprecated(since = "1.0.0", note = "text")]
220 pub struct DeprecatedStruct
{
224 #[deprecated(since = "1.0.0", note = "text")]
225 pub struct DeprecatedUnitStruct
;
228 #[deprecated(since = "1.0.0", note = "text")]
232 #[deprecated(since = "1.0.0", note = "text")]
233 pub struct DeprecatedTupleStruct(pub isize);
239 // Only the deprecated cases of the following should generate
240 // errors, because other stability attributes now have meaning
241 // only *across* crates, not within a single crate.
243 type Foo
= MethodTester
;
244 let foo
= MethodTester
;
246 deprecated(); //~ ERROR use of deprecated function `this_crate::deprecated`
247 foo
.method_deprecated(); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated`
248 Foo
::method_deprecated(&foo
); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated`
249 <Foo
>::method_deprecated(&foo
); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated`
250 foo
.trait_deprecated(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated`
251 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated`
252 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated`
253 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated`
255 deprecated_text(); //~ ERROR use of deprecated function `this_crate::deprecated_text`: text
256 foo
.method_deprecated_text(); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text
257 Foo
::method_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text
258 <Foo
>::method_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text
259 foo
.trait_deprecated_text(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
260 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
261 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
262 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
264 // Future deprecations are only permitted for rustc_deprecated.
265 deprecated_future(); //~ ERROR use of deprecated function
266 deprecated_future_text(); //~ ERROR use of deprecated function
268 let _
= DeprecatedStruct
{
269 //~^ ERROR use of deprecated struct `this_crate::DeprecatedStruct`: text
270 i
: 0 //~ ERROR use of deprecated field `this_crate::DeprecatedStruct::i`: text
273 let _
= DeprecatedUnitStruct
; //~ ERROR use of deprecated unit struct `this_crate::DeprecatedUnitStruct`: text
275 let _
= Enum
::DeprecatedVariant
; //~ ERROR use of deprecated unit variant `this_crate::Enum::DeprecatedVariant`: text
277 let _
= DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `this_crate::DeprecatedTupleStruct`: text
279 let _
= nested
::DeprecatedStruct
{
280 //~^ ERROR use of deprecated struct `this_crate::nested::DeprecatedStruct`: text
281 i
: 0 //~ ERROR use of deprecated field `this_crate::nested::DeprecatedStruct::i`: text
284 let _
= nested
::DeprecatedUnitStruct
; //~ ERROR use of deprecated unit struct `this_crate::nested::DeprecatedUnitStruct`: text
286 let _
= nested
::Enum
::DeprecatedVariant
; //~ ERROR use of deprecated unit variant `this_crate::nested::Enum::DeprecatedVariant`: text
288 let _
= nested
::DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `this_crate::nested::DeprecatedTupleStruct`: text
291 fn test_method_param
<Foo
: Trait
>(foo
: Foo
) {
292 foo
.trait_deprecated(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated`
293 Trait
::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated`
294 <Foo
>::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated`
295 <Foo
as Trait
>::trait_deprecated(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated`
296 foo
.trait_deprecated_text(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
297 Trait
::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
298 <Foo
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
299 <Foo
as Trait
>::trait_deprecated_text(&foo
); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
302 fn test_method_object(foo
: &Trait
) {
303 foo
.trait_deprecated(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated`
304 foo
.trait_deprecated_text(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
307 #[deprecated(since = "1.0.0", note = "text")]
313 fn test_fn_closure_body() {
317 bar(); //~ ERROR use of deprecated function `this_crate::test_fn_closure_body::{{closure}}#0::bar`
322 #[deprecated(since = "1.0.0", note = "text")]
323 fn test_method_body(&self) {
329 #[deprecated(since = "1.0.0", note = "text")]
330 pub trait DeprecatedTrait
{
336 impl DeprecatedTrait
for S { }
//~ ERROR use of deprecated trait `this_crate::DeprecatedTrait`: text
338 trait LocalTrait
: DeprecatedTrait { }
//~ ERROR use of deprecated trait `this_crate::DeprecatedTrait`: text
343 #[deprecated(since = "1.0.0", note = "text")]
349 #[deprecated(since = "1.0.0", note = "text")] u8);
351 #[deprecated(since = "1.0.0", note = "text")]
356 #[deprecated(since = "1.0.0", note = "text")]
357 struct Deprecated2(u8,
364 //~^ ERROR use of deprecated field `this_crate2::Stable::override2`: text
368 //~^ ERROR use of deprecated field `this_crate2::Stable::override2`: text
372 //~^ ERROR use of deprecated field `this_crate2::Stable::override2`: text
375 let Stable { .. }
= x
;
377 let x
= Stable2(1, 2, 3);
380 //~^ ERROR use of deprecated field `this_crate2::Stable2::2`: text
385 //~^ ERROR use of deprecated field `this_crate2::Stable2::2`: text
391 //~^ ERROR use of deprecated struct `this_crate2::Deprecated`: text
393 //~^ ERROR use of deprecated field `this_crate2::Deprecated::inherit`: text
397 //~^ ERROR use of deprecated field `this_crate2::Deprecated::inherit`: text
400 //~^ ERROR use of deprecated struct `this_crate2::Deprecated`: text
402 //~^ ERROR use of deprecated field `this_crate2::Deprecated::inherit`: text
406 //~^ ERROR use of deprecated struct `this_crate2::Deprecated`: text
407 // the patterns are all fine:
410 let x
= Deprecated2(1, 2, 3);
411 //~^ ERROR use of deprecated tuple struct `this_crate2::Deprecated2`: text
414 //~^ ERROR use of deprecated field `this_crate2::Deprecated2::0`: text
416 //~^ ERROR use of deprecated field `this_crate2::Deprecated2::1`: text
418 //~^ ERROR use of deprecated field `this_crate2::Deprecated2::2`: text
421 //~^ ERROR use of deprecated tuple struct `this_crate2::Deprecated2`: text
423 //~^ ERROR use of deprecated field `this_crate2::Deprecated2::0`: text
425 //~^ ERROR use of deprecated field `this_crate2::Deprecated2::1`: text
427 //~^ ERROR use of deprecated field `this_crate2::Deprecated2::2`: text
430 //~^ ERROR use of deprecated tuple struct `this_crate2::Deprecated2`: text
431 // the patterns are all fine: