2015-12-04 10:34:28 -06:00
|
|
|
// aux-build:deprecation-lint.rs
|
|
|
|
|
|
|
|
#![deny(deprecated)]
|
|
|
|
#![allow(warnings)]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate deprecation_lint;
|
|
|
|
|
|
|
|
mod cross_crate {
|
|
|
|
use deprecation_lint::*;
|
|
|
|
|
|
|
|
fn test() {
|
|
|
|
type Foo = MethodTester;
|
|
|
|
let foo = MethodTester;
|
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
deprecated(); //~ ERROR use of deprecated function `deprecation_lint::deprecated`
|
2023-02-21 15:11:08 -06:00
|
|
|
foo.method_deprecated(); //~ ERROR use of deprecated method `deprecation_lint::MethodTester::method_deprecated`
|
|
|
|
Foo::method_deprecated(&foo); //~ ERROR use of deprecated method `deprecation_lint::MethodTester::method_deprecated`
|
|
|
|
<Foo>::method_deprecated(&foo); //~ ERROR use of deprecated method `deprecation_lint::MethodTester::method_deprecated`
|
|
|
|
foo.trait_deprecated(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
|
|
|
|
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
|
|
|
|
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
|
|
|
|
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
|
2020-07-25 12:49:46 -05:00
|
|
|
|
|
|
|
deprecated_text(); //~ ERROR use of deprecated function `deprecation_lint::deprecated_text`: text
|
2023-02-21 15:11:08 -06:00
|
|
|
foo.method_deprecated_text(); //~ ERROR use of deprecated method `deprecation_lint::MethodTester::method_deprecated_text`: text
|
|
|
|
Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::MethodTester::method_deprecated_text`: text
|
|
|
|
<Foo>::method_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::MethodTester::method_deprecated_text`: text
|
|
|
|
foo.trait_deprecated_text(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
|
|
|
|
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
|
|
|
|
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
|
|
|
|
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
|
2020-07-25 12:49:46 -05:00
|
|
|
|
|
|
|
let _ = DeprecatedStruct { //~ ERROR use of deprecated struct `deprecation_lint::DeprecatedStruct`: text
|
|
|
|
i: 0 //~ ERROR use of deprecated field `deprecation_lint::DeprecatedStruct::i`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
};
|
|
|
|
|
2022-02-22 03:53:45 -06:00
|
|
|
let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `deprecation_lint::DeprecatedUnitStruct`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
2022-02-22 03:53:45 -06:00
|
|
|
let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `deprecation_lint::Enum::DeprecatedVariant`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
2022-02-22 03:53:45 -06:00
|
|
|
let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `deprecation_lint::DeprecatedTupleStruct`: text
|
2017-11-01 18:34:44 -05:00
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
let _ = nested::DeprecatedStruct { //~ ERROR use of deprecated struct `deprecation_lint::nested::DeprecatedStruct`: text
|
|
|
|
i: 0 //~ ERROR use of deprecated field `deprecation_lint::nested::DeprecatedStruct::i`: text
|
2017-11-01 18:34:44 -05:00
|
|
|
};
|
|
|
|
|
2022-02-22 03:53:45 -06:00
|
|
|
let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `deprecation_lint::nested::DeprecatedUnitStruct`: text
|
2017-11-01 18:34:44 -05:00
|
|
|
|
2022-02-22 03:53:45 -06:00
|
|
|
let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `deprecation_lint::nested::Enum::DeprecatedVariant`: text
|
2017-11-01 18:34:44 -05:00
|
|
|
|
2022-02-22 03:53:45 -06:00
|
|
|
let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `deprecation_lint::nested::DeprecatedTupleStruct`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
2022-10-12 11:12:19 -05:00
|
|
|
// At the moment, the lint checker only checks stability
|
2015-12-04 10:34:28 -06:00
|
|
|
// in the arguments of macros.
|
|
|
|
// Eventually, we will want to lint the contents of the
|
|
|
|
// macro in the module *defining* it. Also, stability levels
|
|
|
|
// on macros themselves are not yet linted.
|
2020-07-25 12:49:46 -05:00
|
|
|
macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated function `deprecation_lint::deprecated_text`: text
|
|
|
|
macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated function `deprecation_lint::deprecated_text`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_method_param<Foo: Trait>(foo: Foo) {
|
2023-02-21 15:11:08 -06:00
|
|
|
foo.trait_deprecated(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
|
|
|
|
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
|
|
|
|
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
|
|
|
|
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
|
|
|
|
foo.trait_deprecated_text(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
|
|
|
|
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
|
|
|
|
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
|
|
|
|
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_method_object(foo: &Trait) {
|
2023-02-21 15:11:08 -06:00
|
|
|
foo.trait_deprecated(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated`
|
|
|
|
foo.trait_deprecated_text(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
2015-12-12 12:40:45 -06:00
|
|
|
struct S;
|
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
impl DeprecatedTrait for S {} //~ ERROR use of deprecated trait `deprecation_lint::DeprecatedTrait`: text
|
|
|
|
trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated trait `deprecation_lint::DeprecatedTrait`: text
|
2015-12-12 12:40:45 -06:00
|
|
|
|
2015-12-04 10:34:28 -06:00
|
|
|
pub fn foo() {
|
|
|
|
let x = Stable {
|
|
|
|
override2: 3,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Stable::override2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
let _ = x.override2;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Stable::override2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let Stable {
|
|
|
|
override2: _
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Stable::override2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
} = x;
|
|
|
|
// all fine
|
|
|
|
let Stable { .. } = x;
|
|
|
|
|
|
|
|
let x = Stable2(1, 2, 3);
|
|
|
|
|
|
|
|
let _ = x.2;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Stable2::2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let Stable2(_,
|
|
|
|
_,
|
|
|
|
_)
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Stable2::2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
= x;
|
|
|
|
// all fine
|
|
|
|
let Stable2(..) = x;
|
|
|
|
|
|
|
|
let x = Deprecated {
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated struct `deprecation_lint::Deprecated`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
inherit: 1,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated::inherit`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
let _ = x.inherit;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated::inherit`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let Deprecated {
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated struct `deprecation_lint::Deprecated`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
inherit: _,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated::inherit`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
} = x;
|
|
|
|
|
|
|
|
let Deprecated
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated struct `deprecation_lint::Deprecated`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
{ .. } = x;
|
|
|
|
|
|
|
|
let x = Deprecated2(1, 2, 3);
|
2022-02-22 03:53:45 -06:00
|
|
|
//~^ ERROR use of deprecated tuple struct `deprecation_lint::Deprecated2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let _ = x.0;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::0`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
let _ = x.1;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::1`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
let _ = x.2;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let Deprecated2
|
2022-02-22 03:53:45 -06:00
|
|
|
//~^ ERROR use of deprecated tuple struct `deprecation_lint::Deprecated2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
(_,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::0`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
_,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::1`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
_)
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
= x;
|
|
|
|
let Deprecated2
|
2022-02-22 03:53:45 -06:00
|
|
|
//~^ ERROR use of deprecated tuple struct `deprecation_lint::Deprecated2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
// the patterns are all fine:
|
|
|
|
(..) = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod inheritance {
|
|
|
|
use deprecation_lint::*;
|
|
|
|
|
|
|
|
fn test_inheritance() {
|
2020-07-25 12:49:46 -05:00
|
|
|
deprecated_mod::deprecated(); //~ ERROR use of deprecated function `deprecation_lint::deprecated_mod::deprecated`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod this_crate {
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub fn deprecated() {}
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub fn deprecated_text() {}
|
|
|
|
|
2018-03-19 12:02:04 -05:00
|
|
|
#[deprecated(since = "99.99.99", note = "text")]
|
|
|
|
pub fn deprecated_future() {}
|
|
|
|
#[deprecated(since = "99.99.99", note = "text")]
|
|
|
|
pub fn deprecated_future_text() {}
|
|
|
|
|
2015-12-04 10:34:28 -06:00
|
|
|
pub struct MethodTester;
|
|
|
|
|
|
|
|
impl MethodTester {
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub fn method_deprecated(&self) {}
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub fn method_deprecated_text(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Trait {
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
fn trait_deprecated(&self) {}
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
fn trait_deprecated_text(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Trait for MethodTester {}
|
|
|
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub struct DeprecatedStruct {
|
|
|
|
i: isize
|
|
|
|
}
|
|
|
|
pub struct UnstableStruct {
|
|
|
|
i: isize
|
|
|
|
}
|
|
|
|
pub struct StableStruct {
|
|
|
|
i: isize
|
|
|
|
}
|
|
|
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub struct DeprecatedUnitStruct;
|
|
|
|
|
|
|
|
pub enum Enum {
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
DeprecatedVariant,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub struct DeprecatedTupleStruct(isize);
|
|
|
|
|
2017-11-01 18:34:44 -05:00
|
|
|
mod nested {
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub struct DeprecatedStruct {
|
|
|
|
i: isize
|
|
|
|
}
|
|
|
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub struct DeprecatedUnitStruct;
|
|
|
|
|
|
|
|
pub enum Enum {
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
DeprecatedVariant,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub struct DeprecatedTupleStruct(pub isize);
|
|
|
|
}
|
|
|
|
|
2015-12-04 10:34:28 -06:00
|
|
|
fn test() {
|
2017-11-01 18:34:44 -05:00
|
|
|
use self::nested;
|
|
|
|
|
2015-12-04 10:34:28 -06:00
|
|
|
// Only the deprecated cases of the following should generate
|
|
|
|
// errors, because other stability attributes now have meaning
|
|
|
|
// only *across* crates, not within a single crate.
|
|
|
|
|
|
|
|
type Foo = MethodTester;
|
|
|
|
let foo = MethodTester;
|
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
deprecated(); //~ ERROR use of deprecated function `this_crate::deprecated`
|
2023-02-21 15:11:08 -06:00
|
|
|
foo.method_deprecated(); //~ ERROR use of deprecated method `this_crate::MethodTester::method_deprecated`
|
|
|
|
Foo::method_deprecated(&foo); //~ ERROR use of deprecated method `this_crate::MethodTester::method_deprecated`
|
|
|
|
<Foo>::method_deprecated(&foo); //~ ERROR use of deprecated method `this_crate::MethodTester::method_deprecated`
|
|
|
|
foo.trait_deprecated(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
|
|
|
|
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
|
|
|
|
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
|
|
|
|
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
|
2020-07-25 12:49:46 -05:00
|
|
|
|
|
|
|
deprecated_text(); //~ ERROR use of deprecated function `this_crate::deprecated_text`: text
|
2023-02-21 15:11:08 -06:00
|
|
|
foo.method_deprecated_text(); //~ ERROR use of deprecated method `this_crate::MethodTester::method_deprecated_text`: text
|
|
|
|
Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::MethodTester::method_deprecated_text`: text
|
|
|
|
<Foo>::method_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::MethodTester::method_deprecated_text`: text
|
|
|
|
foo.trait_deprecated_text(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
|
|
|
|
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
|
|
|
|
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
|
|
|
|
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
2022-04-07 22:44:55 -05:00
|
|
|
// Future deprecations are only permitted with `#![feature(staged_api)]`
|
2020-07-25 12:49:46 -05:00
|
|
|
deprecated_future(); //~ ERROR use of deprecated function
|
|
|
|
deprecated_future_text(); //~ ERROR use of deprecated function
|
2018-03-19 12:02:04 -05:00
|
|
|
|
2015-12-04 10:34:28 -06:00
|
|
|
let _ = DeprecatedStruct {
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated struct `this_crate::DeprecatedStruct`: text
|
|
|
|
i: 0 //~ ERROR use of deprecated field `this_crate::DeprecatedStruct::i`: text
|
2017-11-01 18:34:44 -05:00
|
|
|
};
|
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `this_crate::DeprecatedUnitStruct`: text
|
2017-11-01 18:34:44 -05:00
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `this_crate::Enum::DeprecatedVariant`: text
|
2017-11-01 18:34:44 -05:00
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `this_crate::DeprecatedTupleStruct`: text
|
2017-11-01 18:34:44 -05:00
|
|
|
|
|
|
|
let _ = nested::DeprecatedStruct {
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated struct `this_crate::nested::DeprecatedStruct`: text
|
|
|
|
i: 0 //~ ERROR use of deprecated field `this_crate::nested::DeprecatedStruct::i`: text
|
2021-07-20 22:23:22 -05:00
|
|
|
//~| ERROR field `i` of struct `this_crate::nested::DeprecatedStruct` is private
|
2015-12-04 10:34:28 -06:00
|
|
|
};
|
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `this_crate::nested::DeprecatedUnitStruct`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `this_crate::nested::Enum::DeprecatedVariant`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `this_crate::nested::DeprecatedTupleStruct`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_method_param<Foo: Trait>(foo: Foo) {
|
2023-02-21 15:11:08 -06:00
|
|
|
foo.trait_deprecated(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
|
|
|
|
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
|
|
|
|
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
|
|
|
|
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
|
|
|
|
foo.trait_deprecated_text(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
|
|
|
|
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
|
|
|
|
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
|
|
|
|
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_method_object(foo: &Trait) {
|
2023-02-21 15:11:08 -06:00
|
|
|
foo.trait_deprecated(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated`
|
|
|
|
foo.trait_deprecated_text(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
fn test_fn_body() {
|
|
|
|
fn fn_in_body() {}
|
2016-08-04 09:56:20 -05:00
|
|
|
fn_in_body();
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
2017-11-01 18:34:44 -05:00
|
|
|
fn test_fn_closure_body() {
|
|
|
|
let _ = || {
|
|
|
|
#[deprecated]
|
|
|
|
fn bar() { }
|
2020-08-31 12:11:44 -05:00
|
|
|
bar(); //~ ERROR use of deprecated function `this_crate::test_fn_closure_body::{closure#0}::bar`
|
2017-11-01 18:34:44 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-12-04 10:34:28 -06:00
|
|
|
impl MethodTester {
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
fn test_method_body(&self) {
|
|
|
|
fn fn_in_body() {}
|
2016-08-04 09:56:20 -05:00
|
|
|
fn_in_body();
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
pub trait DeprecatedTrait {
|
|
|
|
fn dummy(&self) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S;
|
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
impl DeprecatedTrait for S { } //~ ERROR use of deprecated trait `this_crate::DeprecatedTrait`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
2020-07-25 12:49:46 -05:00
|
|
|
trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated trait `this_crate::DeprecatedTrait`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
mod this_crate2 {
|
|
|
|
struct Stable {
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
override2: u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Stable2(u8,
|
|
|
|
u8,
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")] u8);
|
|
|
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
struct Deprecated {
|
|
|
|
inherit: u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text")]
|
|
|
|
struct Deprecated2(u8,
|
|
|
|
u8,
|
|
|
|
u8);
|
|
|
|
|
|
|
|
pub fn foo() {
|
|
|
|
let x = Stable {
|
|
|
|
override2: 3,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Stable::override2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
let _ = x.override2;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Stable::override2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let Stable {
|
|
|
|
override2: _
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Stable::override2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
} = x;
|
|
|
|
// all fine
|
|
|
|
let Stable { .. } = x;
|
|
|
|
|
|
|
|
let x = Stable2(1, 2, 3);
|
|
|
|
|
|
|
|
let _ = x.2;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Stable2::2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let Stable2(_,
|
|
|
|
_,
|
|
|
|
_)
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Stable2::2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
= x;
|
|
|
|
// all fine
|
|
|
|
let Stable2(..) = x;
|
|
|
|
|
|
|
|
let x = Deprecated {
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated struct `this_crate2::Deprecated`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
inherit: 1,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Deprecated::inherit`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
let _ = x.inherit;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Deprecated::inherit`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let Deprecated {
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated struct `this_crate2::Deprecated`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
inherit: _,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Deprecated::inherit`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
} = x;
|
|
|
|
|
|
|
|
let Deprecated
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated struct `this_crate2::Deprecated`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
// the patterns are all fine:
|
|
|
|
{ .. } = x;
|
|
|
|
|
|
|
|
let x = Deprecated2(1, 2, 3);
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated tuple struct `this_crate2::Deprecated2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let _ = x.0;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Deprecated2::0`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
let _ = x.1;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Deprecated2::1`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
let _ = x.2;
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Deprecated2::2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
|
|
|
|
let Deprecated2
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated tuple struct `this_crate2::Deprecated2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
(_,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Deprecated2::0`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
_,
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Deprecated2::1`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
_)
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated field `this_crate2::Deprecated2::2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
= x;
|
|
|
|
let Deprecated2
|
2020-07-25 12:49:46 -05:00
|
|
|
//~^ ERROR use of deprecated tuple struct `this_crate2::Deprecated2`: text
|
2015-12-04 10:34:28 -06:00
|
|
|
// the patterns are all fine:
|
|
|
|
(..) = x;
|
|
|
|
}
|
2021-06-04 17:14:32 -05:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[deprecated(note = "Use something else instead")]
|
|
|
|
enum DeprecatedDebugEnum {
|
|
|
|
Variant1 { value: Option<String> },
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(deprecated)]
|
|
|
|
impl DeprecatedDebugEnum {
|
|
|
|
fn new() -> Self {
|
|
|
|
DeprecatedDebugEnum::Variant1 { value: None }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(deprecated)]
|
|
|
|
pub fn allow_dep() {
|
|
|
|
let _ = DeprecatedDebugEnum::new();
|
|
|
|
}
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|