From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/deprecation/atomic_initializers.fixed | 11 + src/test/ui/deprecation/atomic_initializers.rs | 11 + src/test/ui/deprecation/atomic_initializers.stderr | 14 + .../ui/deprecation/auxiliary/deprecation-lint.rs | 98 +++ .../deprecation/deprecated-macro_escape-inner.rs | 8 + .../deprecated-macro_escape-inner.stderr | 10 + src/test/ui/deprecation/deprecated-macro_escape.rs | 6 + .../ui/deprecation/deprecated-macro_escape.stderr | 8 + .../ui/deprecation/deprecated_no_stack_check.rs | 6 + .../deprecation/deprecated_no_stack_check.stderr | 9 + src/test/ui/deprecation/deprecation-in-future.rs | 13 + .../ui/deprecation/deprecation-in-future.stderr | 10 + src/test/ui/deprecation/deprecation-lint-2.rs | 13 + src/test/ui/deprecation/deprecation-lint-2.stderr | 15 + src/test/ui/deprecation/deprecation-lint-3.rs | 14 + src/test/ui/deprecation/deprecation-lint-3.stderr | 14 + src/test/ui/deprecation/deprecation-lint-nested.rs | 71 ++ .../ui/deprecation/deprecation-lint-nested.stderr | 44 ++ src/test/ui/deprecation/deprecation-lint.rs | 454 +++++++++++++ src/test/ui/deprecation/deprecation-lint.stderr | 747 +++++++++++++++++++++ src/test/ui/deprecation/deprecation-sanity.rs | 42 ++ src/test/ui/deprecation/deprecation-sanity.stderr | 72 ++ src/test/ui/deprecation/derive_on_deprecated.rs | 15 + .../deprecation/derive_on_deprecated_forbidden.rs | 9 + .../feature-gate-deprecated_suggestion.rs | 6 + .../feature-gate-deprecated_suggestion.stderr | 11 + src/test/ui/deprecation/invalid-literal.rs | 4 + src/test/ui/deprecation/invalid-literal.stderr | 17 + ...issue-66340-deprecated-attr-non-meta-grammar.rs | 11 + ...e-66340-deprecated-attr-non-meta-grammar.stderr | 8 + ...ssue-84637-deprecated-associated-function.fixed | 9 + .../issue-84637-deprecated-associated-function.rs | 9 + ...sue-84637-deprecated-associated-function.stderr | 29 + .../ui/deprecation/staged-deprecation-in-future.rs | 18 + .../staged-deprecation-in-future.stderr | 20 + src/test/ui/deprecation/suggestion.fixed | 43 ++ src/test/ui/deprecation/suggestion.rs | 43 ++ src/test/ui/deprecation/suggestion.stderr | 29 + src/test/ui/deprecation/try-macro-suggestion.rs | 9 + .../ui/deprecation/try-macro-suggestion.stderr | 31 + 40 files changed, 2011 insertions(+) create mode 100644 src/test/ui/deprecation/atomic_initializers.fixed create mode 100644 src/test/ui/deprecation/atomic_initializers.rs create mode 100644 src/test/ui/deprecation/atomic_initializers.stderr create mode 100644 src/test/ui/deprecation/auxiliary/deprecation-lint.rs create mode 100644 src/test/ui/deprecation/deprecated-macro_escape-inner.rs create mode 100644 src/test/ui/deprecation/deprecated-macro_escape-inner.stderr create mode 100644 src/test/ui/deprecation/deprecated-macro_escape.rs create mode 100644 src/test/ui/deprecation/deprecated-macro_escape.stderr create mode 100644 src/test/ui/deprecation/deprecated_no_stack_check.rs create mode 100644 src/test/ui/deprecation/deprecated_no_stack_check.stderr create mode 100644 src/test/ui/deprecation/deprecation-in-future.rs create mode 100644 src/test/ui/deprecation/deprecation-in-future.stderr create mode 100644 src/test/ui/deprecation/deprecation-lint-2.rs create mode 100644 src/test/ui/deprecation/deprecation-lint-2.stderr create mode 100644 src/test/ui/deprecation/deprecation-lint-3.rs create mode 100644 src/test/ui/deprecation/deprecation-lint-3.stderr create mode 100644 src/test/ui/deprecation/deprecation-lint-nested.rs create mode 100644 src/test/ui/deprecation/deprecation-lint-nested.stderr create mode 100644 src/test/ui/deprecation/deprecation-lint.rs create mode 100644 src/test/ui/deprecation/deprecation-lint.stderr create mode 100644 src/test/ui/deprecation/deprecation-sanity.rs create mode 100644 src/test/ui/deprecation/deprecation-sanity.stderr create mode 100644 src/test/ui/deprecation/derive_on_deprecated.rs create mode 100644 src/test/ui/deprecation/derive_on_deprecated_forbidden.rs create mode 100644 src/test/ui/deprecation/feature-gate-deprecated_suggestion.rs create mode 100644 src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr create mode 100644 src/test/ui/deprecation/invalid-literal.rs create mode 100644 src/test/ui/deprecation/invalid-literal.stderr create mode 100644 src/test/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs create mode 100644 src/test/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr create mode 100644 src/test/ui/deprecation/issue-84637-deprecated-associated-function.fixed create mode 100644 src/test/ui/deprecation/issue-84637-deprecated-associated-function.rs create mode 100644 src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr create mode 100644 src/test/ui/deprecation/staged-deprecation-in-future.rs create mode 100644 src/test/ui/deprecation/staged-deprecation-in-future.stderr create mode 100644 src/test/ui/deprecation/suggestion.fixed create mode 100644 src/test/ui/deprecation/suggestion.rs create mode 100644 src/test/ui/deprecation/suggestion.stderr create mode 100644 src/test/ui/deprecation/try-macro-suggestion.rs create mode 100644 src/test/ui/deprecation/try-macro-suggestion.stderr (limited to 'src/test/ui/deprecation') diff --git a/src/test/ui/deprecation/atomic_initializers.fixed b/src/test/ui/deprecation/atomic_initializers.fixed new file mode 100644 index 000000000..4fb0aeeb5 --- /dev/null +++ b/src/test/ui/deprecation/atomic_initializers.fixed @@ -0,0 +1,11 @@ +// run-rustfix +// check-pass + +#[allow(deprecated, unused_imports)] +use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT}; + +#[allow(dead_code)] +static FOO: AtomicIsize = AtomicIsize::new(0); +//~^ WARN use of deprecated constant + +fn main() {} diff --git a/src/test/ui/deprecation/atomic_initializers.rs b/src/test/ui/deprecation/atomic_initializers.rs new file mode 100644 index 000000000..1dcfd36d7 --- /dev/null +++ b/src/test/ui/deprecation/atomic_initializers.rs @@ -0,0 +1,11 @@ +// run-rustfix +// check-pass + +#[allow(deprecated, unused_imports)] +use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT}; + +#[allow(dead_code)] +static FOO: AtomicIsize = ATOMIC_ISIZE_INIT; +//~^ WARN use of deprecated constant + +fn main() {} diff --git a/src/test/ui/deprecation/atomic_initializers.stderr b/src/test/ui/deprecation/atomic_initializers.stderr new file mode 100644 index 000000000..30fcc9de6 --- /dev/null +++ b/src/test/ui/deprecation/atomic_initializers.stderr @@ -0,0 +1,14 @@ +warning: use of deprecated constant `std::sync::atomic::ATOMIC_ISIZE_INIT`: the `new` function is now preferred + --> $DIR/atomic_initializers.rs:8:27 + | +LL | static FOO: AtomicIsize = ATOMIC_ISIZE_INIT; + | ^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(deprecated)]` on by default +help: replace the use of the deprecated constant + | +LL | static FOO: AtomicIsize = AtomicIsize::new(0); + | ~~~~~~~~~~~~~~~~~~~ + +warning: 1 warning emitted + diff --git a/src/test/ui/deprecation/auxiliary/deprecation-lint.rs b/src/test/ui/deprecation/auxiliary/deprecation-lint.rs new file mode 100644 index 000000000..948bf1cb7 --- /dev/null +++ b/src/test/ui/deprecation/auxiliary/deprecation-lint.rs @@ -0,0 +1,98 @@ +#![feature(deprecated)] + +#[deprecated(since = "1.0.0", note = "text")] +pub fn deprecated() {} +#[deprecated(since = "1.0.0", note = "text")] +pub fn deprecated_text() {} + +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) {} +} + +#[deprecated(since = "1.0.0", note = "text")] +pub trait DeprecatedTrait { fn dummy(&self) { } } + +impl Trait for MethodTester {} + +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedStruct { + pub 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); + +pub mod nested { + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedStruct { + pub 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); +} + +pub struct Stable { + #[deprecated(since = "1.0.0", note = "text")] + pub override2: u8, +} + +pub struct Stable2(pub u8, pub u8, #[deprecated(since = "1.0.0", note = "text")] pub u8); + +#[deprecated(since = "1.0.0", note = "text")] +pub struct Deprecated { + pub inherit: u8, +} + +#[deprecated(since = "1.0.0", note = "text")] +pub struct Deprecated2(pub u8, + pub u8, + pub u8); + +#[deprecated(since = "1.0.0", note = "text")] +pub mod deprecated_mod { + pub fn deprecated() {} +} + +#[macro_export] +macro_rules! macro_test { + () => (deprecated()); +} + +#[macro_export] +macro_rules! macro_test_arg { + ($func:expr) => ($func); +} + +#[macro_export] +macro_rules! macro_test_arg_nested { + ($func:ident) => (macro_test_arg!($func())); +} diff --git a/src/test/ui/deprecation/deprecated-macro_escape-inner.rs b/src/test/ui/deprecation/deprecated-macro_escape-inner.rs new file mode 100644 index 000000000..e2957c422 --- /dev/null +++ b/src/test/ui/deprecation/deprecated-macro_escape-inner.rs @@ -0,0 +1,8 @@ +// run-pass + +mod foo { + #![macro_escape] //~ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]` +} + +fn main() { +} diff --git a/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr b/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr new file mode 100644 index 000000000..5b866bbbe --- /dev/null +++ b/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr @@ -0,0 +1,10 @@ +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` + --> $DIR/deprecated-macro_escape-inner.rs:4:5 + | +LL | #![macro_escape] + | ^^^^^^^^^^^^^^^^ + | + = help: try an outer attribute: `#[macro_use]` + +warning: 1 warning emitted + diff --git a/src/test/ui/deprecation/deprecated-macro_escape.rs b/src/test/ui/deprecation/deprecated-macro_escape.rs new file mode 100644 index 000000000..4a89b4062 --- /dev/null +++ b/src/test/ui/deprecation/deprecated-macro_escape.rs @@ -0,0 +1,6 @@ +// run-pass + +#[macro_escape] //~ WARNING `#[macro_escape]` is a deprecated synonym for `#[macro_use]` +mod foo {} + +fn main() {} diff --git a/src/test/ui/deprecation/deprecated-macro_escape.stderr b/src/test/ui/deprecation/deprecated-macro_escape.stderr new file mode 100644 index 000000000..0bb8dc17e --- /dev/null +++ b/src/test/ui/deprecation/deprecated-macro_escape.stderr @@ -0,0 +1,8 @@ +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` + --> $DIR/deprecated-macro_escape.rs:3:1 + | +LL | #[macro_escape] + | ^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/src/test/ui/deprecation/deprecated_no_stack_check.rs b/src/test/ui/deprecation/deprecated_no_stack_check.rs new file mode 100644 index 000000000..8e1f5bbf0 --- /dev/null +++ b/src/test/ui/deprecation/deprecated_no_stack_check.rs @@ -0,0 +1,6 @@ +#![deny(warnings)] +#![feature(no_stack_check)] +//~^ ERROR: feature has been removed [E0557] +fn main() { + +} diff --git a/src/test/ui/deprecation/deprecated_no_stack_check.stderr b/src/test/ui/deprecation/deprecated_no_stack_check.stderr new file mode 100644 index 000000000..141664c10 --- /dev/null +++ b/src/test/ui/deprecation/deprecated_no_stack_check.stderr @@ -0,0 +1,9 @@ +error[E0557]: feature has been removed + --> $DIR/deprecated_no_stack_check.rs:2:12 + | +LL | #![feature(no_stack_check)] + | ^^^^^^^^^^^^^^ feature has been removed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0557`. diff --git a/src/test/ui/deprecation/deprecation-in-future.rs b/src/test/ui/deprecation/deprecation-in-future.rs new file mode 100644 index 000000000..fb2a9a401 --- /dev/null +++ b/src/test/ui/deprecation/deprecation-in-future.rs @@ -0,0 +1,13 @@ +// check-pass + +#![deny(deprecated_in_future)] + +#[deprecated(since = "99.99.99", note = "text")] +pub fn deprecated_future() {} + +fn test() { + deprecated_future(); // ok; deprecated_in_future only applies with `#![feature(staged_api)]` + //~^ WARNING use of deprecated function `deprecated_future`: text [deprecated] +} + +fn main() {} diff --git a/src/test/ui/deprecation/deprecation-in-future.stderr b/src/test/ui/deprecation/deprecation-in-future.stderr new file mode 100644 index 000000000..99d1c7341 --- /dev/null +++ b/src/test/ui/deprecation/deprecation-in-future.stderr @@ -0,0 +1,10 @@ +warning: use of deprecated function `deprecated_future`: text + --> $DIR/deprecation-in-future.rs:9:5 + | +LL | deprecated_future(); // ok; deprecated_in_future only applies with `#![feature(staged_api)]` + | ^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(deprecated)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/ui/deprecation/deprecation-lint-2.rs b/src/test/ui/deprecation/deprecation-lint-2.rs new file mode 100644 index 000000000..16ed6d4ec --- /dev/null +++ b/src/test/ui/deprecation/deprecation-lint-2.rs @@ -0,0 +1,13 @@ +// aux-build:deprecation-lint.rs +// error-pattern: use of deprecated function + +#![deny(deprecated)] + +#[macro_use] +extern crate deprecation_lint; + +use deprecation_lint::*; + +fn main() { + macro_test!(); +} diff --git a/src/test/ui/deprecation/deprecation-lint-2.stderr b/src/test/ui/deprecation/deprecation-lint-2.stderr new file mode 100644 index 000000000..a73e56052 --- /dev/null +++ b/src/test/ui/deprecation/deprecation-lint-2.stderr @@ -0,0 +1,15 @@ +error: use of deprecated function `deprecation_lint::deprecated`: text + --> $DIR/deprecation-lint-2.rs:12:5 + | +LL | macro_test!(); + | ^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/deprecation-lint-2.rs:4:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + = note: this error originates in the macro `macro_test` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/deprecation/deprecation-lint-3.rs b/src/test/ui/deprecation/deprecation-lint-3.rs new file mode 100644 index 000000000..e6e1587da --- /dev/null +++ b/src/test/ui/deprecation/deprecation-lint-3.rs @@ -0,0 +1,14 @@ +// aux-build:deprecation-lint.rs +// error-pattern: use of deprecated function + +#![deny(deprecated)] +#![allow(warnings)] + +#[macro_use] +extern crate deprecation_lint; + +use deprecation_lint::*; + +fn main() { + macro_test_arg_nested!(deprecated_text); +} diff --git a/src/test/ui/deprecation/deprecation-lint-3.stderr b/src/test/ui/deprecation/deprecation-lint-3.stderr new file mode 100644 index 000000000..f499ff85e --- /dev/null +++ b/src/test/ui/deprecation/deprecation-lint-3.stderr @@ -0,0 +1,14 @@ +error: use of deprecated function `deprecation_lint::deprecated_text`: text + --> $DIR/deprecation-lint-3.rs:13:28 + | +LL | macro_test_arg_nested!(deprecated_text); + | ^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/deprecation-lint-3.rs:4:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/deprecation/deprecation-lint-nested.rs b/src/test/ui/deprecation/deprecation-lint-nested.rs new file mode 100644 index 000000000..589522cdb --- /dev/null +++ b/src/test/ui/deprecation/deprecation-lint-nested.rs @@ -0,0 +1,71 @@ +#![deny(deprecated)] +#![allow(warnings)] + +#[deprecated] +fn issue_35128() { + format_args!("foo"); +} + +#[deprecated] +fn issue_35128_minimal() { + static FOO: &'static str = "foo"; + let _ = FOO; +} + +#[deprecated] +mod silent { + type DeprecatedType = u8; + struct DeprecatedStruct; + fn deprecated_fn() {} + trait DeprecatedTrait {} + static DEPRECATED_STATIC: u8 = 0; + const DEPRECATED_CONST: u8 = 1; + + struct Foo(DeprecatedType); + + impl DeprecatedTrait for Foo {} + + impl Foo { + fn bar() { + deprecated_fn(); + } + } + + fn foo() -> u8 { + DEPRECATED_STATIC + + DEPRECATED_CONST + } +} + +#[deprecated] +mod loud { + #[deprecated] + type DeprecatedType = u8; + #[deprecated] + struct DeprecatedStruct; + #[deprecated] + fn deprecated_fn() {} + #[deprecated] + trait DeprecatedTrait {} + #[deprecated] + static DEPRECATED_STATIC: u8 = 0; + #[deprecated] + const DEPRECATED_CONST: u8 = 1; + + struct Foo(DeprecatedType); //~ ERROR use of deprecated type alias + + impl DeprecatedTrait for Foo {} //~ ERROR use of deprecated trait + + impl Foo { + fn bar() { //~ ERROR use of deprecated trait + deprecated_fn(); //~ ERROR use of deprecated function + } + } + + fn foo() -> u8 { + DEPRECATED_STATIC + //~ ERROR use of deprecated static + DEPRECATED_CONST //~ ERROR use of deprecated const + } +} + +fn main() {} diff --git a/src/test/ui/deprecation/deprecation-lint-nested.stderr b/src/test/ui/deprecation/deprecation-lint-nested.stderr new file mode 100644 index 000000000..47607b8cc --- /dev/null +++ b/src/test/ui/deprecation/deprecation-lint-nested.stderr @@ -0,0 +1,44 @@ +error: use of deprecated type alias `loud::DeprecatedType` + --> $DIR/deprecation-lint-nested.rs:55:16 + | +LL | struct Foo(DeprecatedType); + | ^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/deprecation-lint-nested.rs:1:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + +error: use of deprecated trait `loud::DeprecatedTrait` + --> $DIR/deprecation-lint-nested.rs:57:10 + | +LL | impl DeprecatedTrait for Foo {} + | ^^^^^^^^^^^^^^^ + +error: use of deprecated static `loud::DEPRECATED_STATIC` + --> $DIR/deprecation-lint-nested.rs:66:9 + | +LL | DEPRECATED_STATIC + + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated constant `loud::DEPRECATED_CONST` + --> $DIR/deprecation-lint-nested.rs:67:9 + | +LL | DEPRECATED_CONST + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated trait `loud::DeprecatedTrait` + --> $DIR/deprecation-lint-nested.rs:60:19 + | +LL | fn bar() { + | ^^^^^^^^^^^^^^^ + +error: use of deprecated function `loud::deprecated_fn` + --> $DIR/deprecation-lint-nested.rs:61:13 + | +LL | deprecated_fn(); + | ^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/deprecation/deprecation-lint.rs b/src/test/ui/deprecation/deprecation-lint.rs new file mode 100644 index 000000000..65cc4e2ef --- /dev/null +++ b/src/test/ui/deprecation/deprecation-lint.rs @@ -0,0 +1,454 @@ +// 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; + + deprecated(); //~ ERROR use of deprecated function `deprecation_lint::deprecated` + foo.method_deprecated(); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated` + Foo::method_deprecated(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated` + ::method_deprecated(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated` + foo.trait_deprecated(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated` + Trait::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated` + ::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated` + ::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated` + + deprecated_text(); //~ ERROR use of deprecated function `deprecation_lint::deprecated_text`: text + foo.method_deprecated_text(); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text + Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text + ::method_deprecated_text(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text + foo.trait_deprecated_text(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + + let _ = DeprecatedStruct { //~ ERROR use of deprecated struct `deprecation_lint::DeprecatedStruct`: text + i: 0 //~ ERROR use of deprecated field `deprecation_lint::DeprecatedStruct::i`: text + }; + + let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `deprecation_lint::DeprecatedUnitStruct`: text + + let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `deprecation_lint::Enum::DeprecatedVariant`: text + + let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `deprecation_lint::DeprecatedTupleStruct`: text + + 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 + }; + + let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `deprecation_lint::nested::DeprecatedUnitStruct`: text + + let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `deprecation_lint::nested::Enum::DeprecatedVariant`: text + + let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `deprecation_lint::nested::DeprecatedTupleStruct`: text + + // At the moment, the lint checker only checks stability in + // 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. + 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 + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated` + Trait::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated` + ::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated` + ::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated` + foo.trait_deprecated_text(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated` + foo.trait_deprecated_text(); //~ ERROR use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + } + + struct S; + + 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 + + pub fn foo() { + let x = Stable { + override2: 3, + //~^ ERROR use of deprecated field `deprecation_lint::Stable::override2`: text + }; + + let _ = x.override2; + //~^ ERROR use of deprecated field `deprecation_lint::Stable::override2`: text + + let Stable { + override2: _ + //~^ ERROR use of deprecated field `deprecation_lint::Stable::override2`: text + } = x; + // all fine + let Stable { .. } = x; + + let x = Stable2(1, 2, 3); + + let _ = x.2; + //~^ ERROR use of deprecated field `deprecation_lint::Stable2::2`: text + + let Stable2(_, + _, + _) + //~^ ERROR use of deprecated field `deprecation_lint::Stable2::2`: text + = x; + // all fine + let Stable2(..) = x; + + let x = Deprecated { + //~^ ERROR use of deprecated struct `deprecation_lint::Deprecated`: text + inherit: 1, + //~^ ERROR use of deprecated field `deprecation_lint::Deprecated::inherit`: text + }; + + let _ = x.inherit; + //~^ ERROR use of deprecated field `deprecation_lint::Deprecated::inherit`: text + + let Deprecated { + //~^ ERROR use of deprecated struct `deprecation_lint::Deprecated`: text + inherit: _, + //~^ ERROR use of deprecated field `deprecation_lint::Deprecated::inherit`: text + } = x; + + let Deprecated + //~^ ERROR use of deprecated struct `deprecation_lint::Deprecated`: text + { .. } = x; + + let x = Deprecated2(1, 2, 3); + //~^ ERROR use of deprecated tuple struct `deprecation_lint::Deprecated2`: text + + let _ = x.0; + //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::0`: text + let _ = x.1; + //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::1`: text + let _ = x.2; + //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::2`: text + + let Deprecated2 + //~^ ERROR use of deprecated tuple struct `deprecation_lint::Deprecated2`: text + (_, + //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::0`: text + _, + //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::1`: text + _) + //~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::2`: text + = x; + let Deprecated2 + //~^ ERROR use of deprecated tuple struct `deprecation_lint::Deprecated2`: text + // the patterns are all fine: + (..) = x; + } +} + +mod inheritance { + use deprecation_lint::*; + + fn test_inheritance() { + deprecated_mod::deprecated(); //~ ERROR use of deprecated function `deprecation_lint::deprecated_mod::deprecated`: text + } +} + +mod this_crate { + #[deprecated(since = "1.0.0", note = "text")] + pub fn deprecated() {} + #[deprecated(since = "1.0.0", note = "text")] + pub fn deprecated_text() {} + + #[deprecated(since = "99.99.99", note = "text")] + pub fn deprecated_future() {} + #[deprecated(since = "99.99.99", note = "text")] + pub fn deprecated_future_text() {} + + 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); + + 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); + } + + fn test() { + use self::nested; + + // 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; + + deprecated(); //~ ERROR use of deprecated function `this_crate::deprecated` + foo.method_deprecated(); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated` + Foo::method_deprecated(&foo); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated` + ::method_deprecated(&foo); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated` + foo.trait_deprecated(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated` + Trait::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated` + ::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated` + ::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated` + + deprecated_text(); //~ ERROR use of deprecated function `this_crate::deprecated_text`: text + foo.method_deprecated_text(); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text + Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text + ::method_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text + foo.trait_deprecated_text(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + + // Future deprecations are only permitted with `#![feature(staged_api)]` + deprecated_future(); //~ ERROR use of deprecated function + deprecated_future_text(); //~ ERROR use of deprecated function + + let _ = DeprecatedStruct { + //~^ ERROR use of deprecated struct `this_crate::DeprecatedStruct`: text + i: 0 //~ ERROR use of deprecated field `this_crate::DeprecatedStruct::i`: text + }; + + let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `this_crate::DeprecatedUnitStruct`: text + + let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `this_crate::Enum::DeprecatedVariant`: text + + let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `this_crate::DeprecatedTupleStruct`: text + + let _ = nested::DeprecatedStruct { + //~^ ERROR use of deprecated struct `this_crate::nested::DeprecatedStruct`: text + i: 0 //~ ERROR use of deprecated field `this_crate::nested::DeprecatedStruct::i`: text + //~| ERROR field `i` of struct `this_crate::nested::DeprecatedStruct` is private + }; + + let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `this_crate::nested::DeprecatedUnitStruct`: text + + let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `this_crate::nested::Enum::DeprecatedVariant`: text + + let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `this_crate::nested::DeprecatedTupleStruct`: text + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated` + Trait::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated` + ::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated` + ::trait_deprecated(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated` + foo.trait_deprecated_text(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated` + foo.trait_deprecated_text(); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + } + + #[deprecated(since = "1.0.0", note = "text")] + fn test_fn_body() { + fn fn_in_body() {} + fn_in_body(); + } + + fn test_fn_closure_body() { + let _ = || { + #[deprecated] + fn bar() { } + bar(); //~ ERROR use of deprecated function `this_crate::test_fn_closure_body::{closure#0}::bar` + }; + } + + impl MethodTester { + #[deprecated(since = "1.0.0", note = "text")] + fn test_method_body(&self) { + fn fn_in_body() {} + fn_in_body(); + } + } + + #[deprecated(since = "1.0.0", note = "text")] + pub trait DeprecatedTrait { + fn dummy(&self) { } + } + + struct S; + + impl DeprecatedTrait for S { } //~ ERROR use of deprecated trait `this_crate::DeprecatedTrait`: text + + trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated trait `this_crate::DeprecatedTrait`: text +} + +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, + //~^ ERROR use of deprecated field `this_crate2::Stable::override2`: text + }; + + let _ = x.override2; + //~^ ERROR use of deprecated field `this_crate2::Stable::override2`: text + + let Stable { + override2: _ + //~^ ERROR use of deprecated field `this_crate2::Stable::override2`: text + } = x; + // all fine + let Stable { .. } = x; + + let x = Stable2(1, 2, 3); + + let _ = x.2; + //~^ ERROR use of deprecated field `this_crate2::Stable2::2`: text + + let Stable2(_, + _, + _) + //~^ ERROR use of deprecated field `this_crate2::Stable2::2`: text + = x; + // all fine + let Stable2(..) = x; + + let x = Deprecated { + //~^ ERROR use of deprecated struct `this_crate2::Deprecated`: text + inherit: 1, + //~^ ERROR use of deprecated field `this_crate2::Deprecated::inherit`: text + }; + + let _ = x.inherit; + //~^ ERROR use of deprecated field `this_crate2::Deprecated::inherit`: text + + let Deprecated { + //~^ ERROR use of deprecated struct `this_crate2::Deprecated`: text + inherit: _, + //~^ ERROR use of deprecated field `this_crate2::Deprecated::inherit`: text + } = x; + + let Deprecated + //~^ ERROR use of deprecated struct `this_crate2::Deprecated`: text + // the patterns are all fine: + { .. } = x; + + let x = Deprecated2(1, 2, 3); + //~^ ERROR use of deprecated tuple struct `this_crate2::Deprecated2`: text + + let _ = x.0; + //~^ ERROR use of deprecated field `this_crate2::Deprecated2::0`: text + let _ = x.1; + //~^ ERROR use of deprecated field `this_crate2::Deprecated2::1`: text + let _ = x.2; + //~^ ERROR use of deprecated field `this_crate2::Deprecated2::2`: text + + let Deprecated2 + //~^ ERROR use of deprecated tuple struct `this_crate2::Deprecated2`: text + (_, + //~^ ERROR use of deprecated field `this_crate2::Deprecated2::0`: text + _, + //~^ ERROR use of deprecated field `this_crate2::Deprecated2::1`: text + _) + //~^ ERROR use of deprecated field `this_crate2::Deprecated2::2`: text + = x; + let Deprecated2 + //~^ ERROR use of deprecated tuple struct `this_crate2::Deprecated2`: text + // the patterns are all fine: + (..) = x; + } + + #[derive(Debug)] + #[deprecated(note = "Use something else instead")] + enum DeprecatedDebugEnum { + Variant1 { value: Option }, + } + + #[allow(deprecated)] + impl DeprecatedDebugEnum { + fn new() -> Self { + DeprecatedDebugEnum::Variant1 { value: None } + } + } + + #[allow(deprecated)] + pub fn allow_dep() { + let _ = DeprecatedDebugEnum::new(); + } +} + +fn main() {} diff --git a/src/test/ui/deprecation/deprecation-lint.stderr b/src/test/ui/deprecation/deprecation-lint.stderr new file mode 100644 index 000000000..3842f8492 --- /dev/null +++ b/src/test/ui/deprecation/deprecation-lint.stderr @@ -0,0 +1,747 @@ +error: use of deprecated function `deprecation_lint::deprecated`: text + --> $DIR/deprecation-lint.rs:16:9 + | +LL | deprecated(); + | ^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/deprecation-lint.rs:3:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:21:16 + | +LL | Trait::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:23:25 + | +LL | ::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated function `deprecation_lint::deprecated_text`: text + --> $DIR/deprecation-lint.rs:25:9 + | +LL | deprecated_text(); + | ^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:30:16 + | +LL | ... Trait::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:32:25 + | +LL | ... ::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated struct `deprecation_lint::DeprecatedStruct`: text + --> $DIR/deprecation-lint.rs:34:17 + | +LL | let _ = DeprecatedStruct { + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated unit struct `deprecation_lint::DeprecatedUnitStruct`: text + --> $DIR/deprecation-lint.rs:38:17 + | +LL | let _ = DeprecatedUnitStruct; + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated unit variant `deprecation_lint::Enum::DeprecatedVariant`: text + --> $DIR/deprecation-lint.rs:40:23 + | +LL | let _ = Enum::DeprecatedVariant; + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated tuple struct `deprecation_lint::DeprecatedTupleStruct`: text + --> $DIR/deprecation-lint.rs:42:17 + | +LL | let _ = DeprecatedTupleStruct (1); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated struct `deprecation_lint::nested::DeprecatedStruct`: text + --> $DIR/deprecation-lint.rs:44:25 + | +LL | let _ = nested::DeprecatedStruct { + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated unit struct `deprecation_lint::nested::DeprecatedUnitStruct`: text + --> $DIR/deprecation-lint.rs:48:25 + | +LL | let _ = nested::DeprecatedUnitStruct; + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated unit variant `deprecation_lint::nested::Enum::DeprecatedVariant`: text + --> $DIR/deprecation-lint.rs:50:31 + | +LL | ... let _ = nested::Enum::DeprecatedVariant; + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated tuple struct `deprecation_lint::nested::DeprecatedTupleStruct`: text + --> $DIR/deprecation-lint.rs:52:25 + | +LL | ... let _ = nested::DeprecatedTupleStruct (1); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated function `deprecation_lint::deprecated_text`: text + --> $DIR/deprecation-lint.rs:59:25 + | +LL | macro_test_arg!(deprecated_text()); + | ^^^^^^^^^^^^^^^ + +error: use of deprecated function `deprecation_lint::deprecated_text`: text + --> $DIR/deprecation-lint.rs:60:41 + | +LL | macro_test_arg!(macro_test_arg!(deprecated_text())); + | ^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:65:16 + | +LL | Trait::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:67:25 + | +LL | ::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:69:16 + | +LL | ... Trait::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:71:25 + | +LL | ... ::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated trait `deprecation_lint::DeprecatedTrait`: text + --> $DIR/deprecation-lint.rs:81:10 + | +LL | impl DeprecatedTrait for S {} + | ^^^^^^^^^^^^^^^ + +error: use of deprecated trait `deprecation_lint::DeprecatedTrait`: text + --> $DIR/deprecation-lint.rs:82:24 + | +LL | trait LocalTrait : DeprecatedTrait { } + | ^^^^^^^^^^^^^^^ + +error: use of deprecated struct `deprecation_lint::Deprecated`: text + --> $DIR/deprecation-lint.rs:113:17 + | +LL | let x = Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated struct `deprecation_lint::Deprecated`: text + --> $DIR/deprecation-lint.rs:122:13 + | +LL | let Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated struct `deprecation_lint::Deprecated`: text + --> $DIR/deprecation-lint.rs:128:13 + | +LL | let Deprecated + | ^^^^^^^^^^ + +error: use of deprecated tuple struct `deprecation_lint::Deprecated2`: text + --> $DIR/deprecation-lint.rs:132:17 + | +LL | let x = Deprecated2(1, 2, 3); + | ^^^^^^^^^^^ + +error: use of deprecated tuple struct `deprecation_lint::Deprecated2`: text + --> $DIR/deprecation-lint.rs:142:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated tuple struct `deprecation_lint::Deprecated2`: text + --> $DIR/deprecation-lint.rs:151:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated function `deprecation_lint::deprecated_mod::deprecated`: text + --> $DIR/deprecation-lint.rs:162:25 + | +LL | deprecated_mod::deprecated(); + | ^^^^^^^^^^ + +error: use of deprecated function `this_crate::deprecated`: text + --> $DIR/deprecation-lint.rs:245:9 + | +LL | deprecated(); + | ^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:250:16 + | +LL | Trait::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:252:25 + | +LL | ::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated function `this_crate::deprecated_text`: text + --> $DIR/deprecation-lint.rs:254:9 + | +LL | deprecated_text(); + | ^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:259:16 + | +LL | Trait::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:261:25 + | +LL | ... ::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated function `this_crate::deprecated_future`: text + --> $DIR/deprecation-lint.rs:264:9 + | +LL | deprecated_future(); + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated function `this_crate::deprecated_future_text`: text + --> $DIR/deprecation-lint.rs:265:9 + | +LL | deprecated_future_text(); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated struct `this_crate::DeprecatedStruct`: text + --> $DIR/deprecation-lint.rs:267:17 + | +LL | let _ = DeprecatedStruct { + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated unit struct `this_crate::DeprecatedUnitStruct`: text + --> $DIR/deprecation-lint.rs:272:17 + | +LL | let _ = DeprecatedUnitStruct; + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated unit variant `this_crate::Enum::DeprecatedVariant`: text + --> $DIR/deprecation-lint.rs:274:23 + | +LL | let _ = Enum::DeprecatedVariant; + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated tuple struct `this_crate::DeprecatedTupleStruct`: text + --> $DIR/deprecation-lint.rs:276:17 + | +LL | let _ = DeprecatedTupleStruct (1); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated struct `this_crate::nested::DeprecatedStruct`: text + --> $DIR/deprecation-lint.rs:278:25 + | +LL | let _ = nested::DeprecatedStruct { + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated unit struct `this_crate::nested::DeprecatedUnitStruct`: text + --> $DIR/deprecation-lint.rs:284:25 + | +LL | let _ = nested::DeprecatedUnitStruct; + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated unit variant `this_crate::nested::Enum::DeprecatedVariant`: text + --> $DIR/deprecation-lint.rs:286:31 + | +LL | ... let _ = nested::Enum::DeprecatedVariant; + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated tuple struct `this_crate::nested::DeprecatedTupleStruct`: text + --> $DIR/deprecation-lint.rs:288:25 + | +LL | ... let _ = nested::DeprecatedTupleStruct (1); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:293:16 + | +LL | Trait::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:295:25 + | +LL | ::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:297:16 + | +LL | Trait::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:299:25 + | +LL | ... ::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated function `this_crate::test_fn_closure_body::{closure#0}::bar` + --> $DIR/deprecation-lint.rs:317:13 + | +LL | bar(); + | ^^^ + +error: use of deprecated trait `this_crate::DeprecatedTrait`: text + --> $DIR/deprecation-lint.rs:336:10 + | +LL | impl DeprecatedTrait for S { } + | ^^^^^^^^^^^^^^^ + +error: use of deprecated trait `this_crate::DeprecatedTrait`: text + --> $DIR/deprecation-lint.rs:338:24 + | +LL | trait LocalTrait : DeprecatedTrait { } + | ^^^^^^^^^^^^^^^ + +error: use of deprecated struct `this_crate2::Deprecated`: text + --> $DIR/deprecation-lint.rs:390:17 + | +LL | let x = Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated struct `this_crate2::Deprecated`: text + --> $DIR/deprecation-lint.rs:399:13 + | +LL | let Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated struct `this_crate2::Deprecated`: text + --> $DIR/deprecation-lint.rs:405:13 + | +LL | let Deprecated + | ^^^^^^^^^^ + +error: use of deprecated tuple struct `this_crate2::Deprecated2`: text + --> $DIR/deprecation-lint.rs:410:17 + | +LL | let x = Deprecated2(1, 2, 3); + | ^^^^^^^^^^^ + +error: use of deprecated tuple struct `this_crate2::Deprecated2`: text + --> $DIR/deprecation-lint.rs:420:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated tuple struct `this_crate2::Deprecated2`: text + --> $DIR/deprecation-lint.rs:429:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated`: text + --> $DIR/deprecation-lint.rs:17:13 + | +LL | foo.method_deprecated(); + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated`: text + --> $DIR/deprecation-lint.rs:18:14 + | +LL | Foo::method_deprecated(&foo); + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated`: text + --> $DIR/deprecation-lint.rs:19:16 + | +LL | ::method_deprecated(&foo); + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:20:13 + | +LL | foo.trait_deprecated(); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:22:16 + | +LL | ::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text + --> $DIR/deprecation-lint.rs:26:13 + | +LL | ... foo.method_deprecated_text(); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text + --> $DIR/deprecation-lint.rs:27:14 + | +LL | ... Foo::method_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text + --> $DIR/deprecation-lint.rs:28:16 + | +LL | ... ::method_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:29:13 + | +LL | foo.trait_deprecated_text(); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:31:16 + | +LL | ... ::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated field `deprecation_lint::DeprecatedStruct::i`: text + --> $DIR/deprecation-lint.rs:35:13 + | +LL | i: 0 + | ^^^^ + +error: use of deprecated field `deprecation_lint::nested::DeprecatedStruct::i`: text + --> $DIR/deprecation-lint.rs:45:13 + | +LL | i: 0 + | ^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:64:13 + | +LL | foo.trait_deprecated(); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:66:16 + | +LL | ::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:68:13 + | +LL | foo.trait_deprecated_text(); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:70:16 + | +LL | ... ::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:75:13 + | +LL | foo.trait_deprecated(); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:76:13 + | +LL | foo.trait_deprecated_text(); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated field `deprecation_lint::Stable::override2`: text + --> $DIR/deprecation-lint.rs:86:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated field `deprecation_lint::Stable::override2`: text + --> $DIR/deprecation-lint.rs:90:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated field `deprecation_lint::Stable::override2`: text + --> $DIR/deprecation-lint.rs:94:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated field `deprecation_lint::Stable2::2`: text + --> $DIR/deprecation-lint.rs:102:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated field `deprecation_lint::Stable2::2`: text + --> $DIR/deprecation-lint.rs:107:20 + | +LL | _) + | ^ + +error: use of deprecated field `deprecation_lint::Deprecated::inherit`: text + --> $DIR/deprecation-lint.rs:115:13 + | +LL | inherit: 1, + | ^^^^^^^^^^ + +error: use of deprecated field `deprecation_lint::Deprecated::inherit`: text + --> $DIR/deprecation-lint.rs:119:17 + | +LL | let _ = x.inherit; + | ^^^^^^^^^ + +error: use of deprecated field `deprecation_lint::Deprecated::inherit`: text + --> $DIR/deprecation-lint.rs:124:13 + | +LL | inherit: _, + | ^^^^^^^^^^ + +error: use of deprecated field `deprecation_lint::Deprecated2::0`: text + --> $DIR/deprecation-lint.rs:135:17 + | +LL | let _ = x.0; + | ^^^ + +error: use of deprecated field `deprecation_lint::Deprecated2::1`: text + --> $DIR/deprecation-lint.rs:137:17 + | +LL | let _ = x.1; + | ^^^ + +error: use of deprecated field `deprecation_lint::Deprecated2::2`: text + --> $DIR/deprecation-lint.rs:139:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated field `deprecation_lint::Deprecated2::0`: text + --> $DIR/deprecation-lint.rs:144:14 + | +LL | (_, + | ^ + +error: use of deprecated field `deprecation_lint::Deprecated2::1`: text + --> $DIR/deprecation-lint.rs:146:14 + | +LL | _, + | ^ + +error: use of deprecated field `deprecation_lint::Deprecated2::2`: text + --> $DIR/deprecation-lint.rs:148:14 + | +LL | _) + | ^ + +error: use of deprecated associated function `this_crate::MethodTester::method_deprecated`: text + --> $DIR/deprecation-lint.rs:246:13 + | +LL | foo.method_deprecated(); + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::MethodTester::method_deprecated`: text + --> $DIR/deprecation-lint.rs:247:14 + | +LL | Foo::method_deprecated(&foo); + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::MethodTester::method_deprecated`: text + --> $DIR/deprecation-lint.rs:248:16 + | +LL | ::method_deprecated(&foo); + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:249:13 + | +LL | foo.trait_deprecated(); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:251:16 + | +LL | ::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text + --> $DIR/deprecation-lint.rs:255:13 + | +LL | ... foo.method_deprecated_text(); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text + --> $DIR/deprecation-lint.rs:256:14 + | +LL | ... Foo::method_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text + --> $DIR/deprecation-lint.rs:257:16 + | +LL | ... ::method_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:258:13 + | +LL | foo.trait_deprecated_text(); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:260:16 + | +LL | ::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated field `this_crate::DeprecatedStruct::i`: text + --> $DIR/deprecation-lint.rs:269:13 + | +LL | i: 0 + | ^^^^ + +error: use of deprecated field `this_crate::nested::DeprecatedStruct::i`: text + --> $DIR/deprecation-lint.rs:280:13 + | +LL | i: 0 + | ^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:292:13 + | +LL | foo.trait_deprecated(); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:294:16 + | +LL | ::trait_deprecated(&foo); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:296:13 + | +LL | foo.trait_deprecated_text(); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:298:16 + | +LL | ::trait_deprecated_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text + --> $DIR/deprecation-lint.rs:303:13 + | +LL | foo.trait_deprecated(); + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text + --> $DIR/deprecation-lint.rs:304:13 + | +LL | foo.trait_deprecated_text(); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated field `this_crate2::Stable::override2`: text + --> $DIR/deprecation-lint.rs:363:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated field `this_crate2::Stable::override2`: text + --> $DIR/deprecation-lint.rs:367:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated field `this_crate2::Stable::override2`: text + --> $DIR/deprecation-lint.rs:371:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated field `this_crate2::Stable2::2`: text + --> $DIR/deprecation-lint.rs:379:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated field `this_crate2::Stable2::2`: text + --> $DIR/deprecation-lint.rs:384:20 + | +LL | _) + | ^ + +error: use of deprecated field `this_crate2::Deprecated::inherit`: text + --> $DIR/deprecation-lint.rs:392:13 + | +LL | inherit: 1, + | ^^^^^^^^^^ + +error: use of deprecated field `this_crate2::Deprecated::inherit`: text + --> $DIR/deprecation-lint.rs:396:17 + | +LL | let _ = x.inherit; + | ^^^^^^^^^ + +error: use of deprecated field `this_crate2::Deprecated::inherit`: text + --> $DIR/deprecation-lint.rs:401:13 + | +LL | inherit: _, + | ^^^^^^^^^^ + +error: use of deprecated field `this_crate2::Deprecated2::0`: text + --> $DIR/deprecation-lint.rs:413:17 + | +LL | let _ = x.0; + | ^^^ + +error: use of deprecated field `this_crate2::Deprecated2::1`: text + --> $DIR/deprecation-lint.rs:415:17 + | +LL | let _ = x.1; + | ^^^ + +error: use of deprecated field `this_crate2::Deprecated2::2`: text + --> $DIR/deprecation-lint.rs:417:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated field `this_crate2::Deprecated2::0`: text + --> $DIR/deprecation-lint.rs:422:14 + | +LL | (_, + | ^ + +error: use of deprecated field `this_crate2::Deprecated2::1`: text + --> $DIR/deprecation-lint.rs:424:14 + | +LL | _, + | ^ + +error: use of deprecated field `this_crate2::Deprecated2::2`: text + --> $DIR/deprecation-lint.rs:426:14 + | +LL | _) + | ^ + +error[E0451]: field `i` of struct `this_crate::nested::DeprecatedStruct` is private + --> $DIR/deprecation-lint.rs:280:13 + | +LL | i: 0 + | ^^^^ private field + +error: aborting due to 123 previous errors + +For more information about this error, try `rustc --explain E0451`. diff --git a/src/test/ui/deprecation/deprecation-sanity.rs b/src/test/ui/deprecation/deprecation-sanity.rs new file mode 100644 index 000000000..9ea75b68f --- /dev/null +++ b/src/test/ui/deprecation/deprecation-sanity.rs @@ -0,0 +1,42 @@ +// Various checks that deprecation attributes are used correctly + +mod bogus_attribute_types_1 { + #[deprecated(since = "a", note = "a", reason)] //~ ERROR unknown meta item 'reason' + fn f1() { } + + #[deprecated(since = "a", note)] //~ ERROR incorrect meta item + fn f2() { } + + #[deprecated(since, note = "a")] //~ ERROR incorrect meta item + fn f3() { } + + #[deprecated(since = "a", note(b))] //~ ERROR incorrect meta item + fn f5() { } + + #[deprecated(since(b), note = "a")] //~ ERROR incorrect meta item + fn f6() { } + + #[deprecated(note = b"test")] //~ ERROR literal in `deprecated` value must be a string + fn f7() { } + + #[deprecated("test")] //~ ERROR item in `deprecated` must be a key/value pair + fn f8() { } +} + +#[deprecated(since = "a", note = "b")] +#[deprecated(since = "a", note = "b")] //~ ERROR multiple `deprecated` attributes +fn multiple1() { } + +#[deprecated(since = "a", since = "b", note = "c")] //~ ERROR multiple 'since' items +fn f1() { } + +struct X; + +#[deprecated = "hello"] //~ ERROR this `#[deprecated]` annotation has no effect +impl Default for X { + fn default() -> Self { + X + } +} + +fn main() { } diff --git a/src/test/ui/deprecation/deprecation-sanity.stderr b/src/test/ui/deprecation/deprecation-sanity.stderr new file mode 100644 index 000000000..973c672df --- /dev/null +++ b/src/test/ui/deprecation/deprecation-sanity.stderr @@ -0,0 +1,72 @@ +error: multiple `deprecated` attributes + --> $DIR/deprecation-sanity.rs:27:1 + | +LL | #[deprecated(since = "a", note = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/deprecation-sanity.rs:26:1 + | +LL | #[deprecated(since = "a", note = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0541]: unknown meta item 'reason' + --> $DIR/deprecation-sanity.rs:4:43 + | +LL | #[deprecated(since = "a", note = "a", reason)] + | ^^^^^^ expected one of `since`, `note` + +error[E0551]: incorrect meta item + --> $DIR/deprecation-sanity.rs:7:31 + | +LL | #[deprecated(since = "a", note)] + | ^^^^ + +error[E0551]: incorrect meta item + --> $DIR/deprecation-sanity.rs:10:18 + | +LL | #[deprecated(since, note = "a")] + | ^^^^^ + +error[E0551]: incorrect meta item + --> $DIR/deprecation-sanity.rs:13:31 + | +LL | #[deprecated(since = "a", note(b))] + | ^^^^^^^ + +error[E0551]: incorrect meta item + --> $DIR/deprecation-sanity.rs:16:18 + | +LL | #[deprecated(since(b), note = "a")] + | ^^^^^^^^ + +error[E0565]: literal in `deprecated` value must be a string + --> $DIR/deprecation-sanity.rs:19:25 + | +LL | #[deprecated(note = b"test")] + | ^^^^^^^ help: consider removing the prefix: `"test"` + +error[E0565]: item in `deprecated` must be a key/value pair + --> $DIR/deprecation-sanity.rs:22:18 + | +LL | #[deprecated("test")] + | ^^^^^^ + +error[E0538]: multiple 'since' items + --> $DIR/deprecation-sanity.rs:30:27 + | +LL | #[deprecated(since = "a", since = "b", note = "c")] + | ^^^^^^^^^^^ + +error: this `#[deprecated]` annotation has no effect + --> $DIR/deprecation-sanity.rs:35:1 + | +LL | #[deprecated = "hello"] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute + | + = note: `#[deny(useless_deprecated)]` on by default + +error: aborting due to 10 previous errors + +Some errors have detailed explanations: E0538, E0541, E0551, E0565. +For more information about an error, try `rustc --explain E0538`. diff --git a/src/test/ui/deprecation/derive_on_deprecated.rs b/src/test/ui/deprecation/derive_on_deprecated.rs new file mode 100644 index 000000000..ac771ac81 --- /dev/null +++ b/src/test/ui/deprecation/derive_on_deprecated.rs @@ -0,0 +1,15 @@ +// build-pass (FIXME(62277): could be check-pass?) + +#![deny(deprecated)] + +#[deprecated = "oh no"] +#[derive(Default)] +struct X; + +#[deprecated(note="Do not use this")] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Hash)] +pub struct Step { + _skip: Option, +} + +fn main() {} diff --git a/src/test/ui/deprecation/derive_on_deprecated_forbidden.rs b/src/test/ui/deprecation/derive_on_deprecated_forbidden.rs new file mode 100644 index 000000000..3fd434664 --- /dev/null +++ b/src/test/ui/deprecation/derive_on_deprecated_forbidden.rs @@ -0,0 +1,9 @@ +// build-pass (FIXME(62277): could be check-pass?) + +#![forbid(deprecated)] + +#[deprecated = "oh no"] +#[derive(Default)] +struct X; + +fn main() {} diff --git a/src/test/ui/deprecation/feature-gate-deprecated_suggestion.rs b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.rs new file mode 100644 index 000000000..a2d0023e3 --- /dev/null +++ b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.rs @@ -0,0 +1,6 @@ +// compile-flags: --crate-type=lib + +#![no_implicit_prelude] + +#[deprecated(suggestion = "foo")] //~ ERROR suggestions on deprecated items are unstable +struct Foo {} diff --git a/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr new file mode 100644 index 000000000..438ce3349 --- /dev/null +++ b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr @@ -0,0 +1,11 @@ +error: suggestions on deprecated items are unstable + --> $DIR/feature-gate-deprecated_suggestion.rs:5:14 + | +LL | #[deprecated(suggestion = "foo")] + | ^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(deprecated_suggestion)]` to the crate root + = note: see #94785 for more details + +error: aborting due to previous error + diff --git a/src/test/ui/deprecation/invalid-literal.rs b/src/test/ui/deprecation/invalid-literal.rs new file mode 100644 index 000000000..fbdfbd160 --- /dev/null +++ b/src/test/ui/deprecation/invalid-literal.rs @@ -0,0 +1,4 @@ +#[deprecated = b"test"] //~ ERROR malformed `deprecated` attribute +fn foo() {} + +fn main() {} diff --git a/src/test/ui/deprecation/invalid-literal.stderr b/src/test/ui/deprecation/invalid-literal.stderr new file mode 100644 index 000000000..b56eedeb8 --- /dev/null +++ b/src/test/ui/deprecation/invalid-literal.stderr @@ -0,0 +1,17 @@ +error: malformed `deprecated` attribute input + --> $DIR/invalid-literal.rs:1:1 + | +LL | #[deprecated = b"test"] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[deprecated = "reason"] + | ~~~~~~~~~~~~~~~~~~~~~~~~ +LL | #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | #[deprecated] + | ~~~~~~~~~~~~~ + +error: aborting due to previous error + diff --git a/src/test/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs b/src/test/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs new file mode 100644 index 000000000..c0cde75d4 --- /dev/null +++ b/src/test/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs @@ -0,0 +1,11 @@ +// The original problem in #66340 was that `find_deprecation_generic` +// called `attr.meta().unwrap()` under the assumption that the attribute +// was a well-formed `MetaItem`. + +fn main() { + foo() +} + +#[deprecated(note = test)] +//~^ ERROR expected unsuffixed literal or identifier, found `test` +fn foo() {} diff --git a/src/test/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr b/src/test/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr new file mode 100644 index 000000000..24178faf8 --- /dev/null +++ b/src/test/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr @@ -0,0 +1,8 @@ +error: expected unsuffixed literal or identifier, found `test` + --> $DIR/issue-66340-deprecated-attr-non-meta-grammar.rs:9:21 + | +LL | #[deprecated(note = test)] + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/deprecation/issue-84637-deprecated-associated-function.fixed b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.fixed new file mode 100644 index 000000000..99a2b0961 --- /dev/null +++ b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.fixed @@ -0,0 +1,9 @@ +// run-rustfix + +#![deny(deprecated)] + +fn main() { + let _foo = str::trim_start(" aoeu"); //~ ERROR use of deprecated associated function `core::str::::trim_left`: superseded by `trim_start` [deprecated] + + let _bar = " aoeu".trim_start(); //~ ERROR use of deprecated associated function `core::str::::trim_left`: superseded by `trim_start` [deprecated] +} diff --git a/src/test/ui/deprecation/issue-84637-deprecated-associated-function.rs b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.rs new file mode 100644 index 000000000..62bf84aa3 --- /dev/null +++ b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.rs @@ -0,0 +1,9 @@ +// run-rustfix + +#![deny(deprecated)] + +fn main() { + let _foo = str::trim_left(" aoeu"); //~ ERROR use of deprecated associated function `core::str::::trim_left`: superseded by `trim_start` [deprecated] + + let _bar = " aoeu".trim_left(); //~ ERROR use of deprecated associated function `core::str::::trim_left`: superseded by `trim_start` [deprecated] +} diff --git a/src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr new file mode 100644 index 000000000..8d4529526 --- /dev/null +++ b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr @@ -0,0 +1,29 @@ +error: use of deprecated associated function `core::str::::trim_left`: superseded by `trim_start` + --> $DIR/issue-84637-deprecated-associated-function.rs:6:21 + | +LL | let _foo = str::trim_left(" aoeu"); + | ^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/issue-84637-deprecated-associated-function.rs:3:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ +help: replace the use of the deprecated associated function + | +LL | let _foo = str::trim_start(" aoeu"); + | ~~~~~~~~~~ + +error: use of deprecated associated function `core::str::::trim_left`: superseded by `trim_start` + --> $DIR/issue-84637-deprecated-associated-function.rs:8:26 + | +LL | let _bar = " aoeu".trim_left(); + | ^^^^^^^^^ + | +help: replace the use of the deprecated associated function + | +LL | let _bar = " aoeu".trim_start(); + | ~~~~~~~~~~ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/deprecation/staged-deprecation-in-future.rs b/src/test/ui/deprecation/staged-deprecation-in-future.rs new file mode 100644 index 000000000..87b15ec30 --- /dev/null +++ b/src/test/ui/deprecation/staged-deprecation-in-future.rs @@ -0,0 +1,18 @@ +#![deny(deprecated_in_future)] + +#![feature(staged_api)] + +#![stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")] + +#[deprecated(since = "99.99.99", note = "effectively never")] +#[stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")] +pub struct S1; + +#[deprecated(since = "TBD", note = "literally never")] +#[stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")] +pub struct S2; + +fn main() { + let _ = S1; //~ ERROR use of unit struct `S1` that will be deprecated in future version 99.99.99: effectively never + let _ = S2; //~ ERROR use of unit struct `S2` that will be deprecated in a future Rust version: literally never +} diff --git a/src/test/ui/deprecation/staged-deprecation-in-future.stderr b/src/test/ui/deprecation/staged-deprecation-in-future.stderr new file mode 100644 index 000000000..13d98044a --- /dev/null +++ b/src/test/ui/deprecation/staged-deprecation-in-future.stderr @@ -0,0 +1,20 @@ +error: use of unit struct `S1` that will be deprecated in future version 99.99.99: effectively never + --> $DIR/staged-deprecation-in-future.rs:16:13 + | +LL | let _ = S1; + | ^^ + | +note: the lint level is defined here + --> $DIR/staged-deprecation-in-future.rs:1:9 + | +LL | #![deny(deprecated_in_future)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of unit struct `S2` that will be deprecated in a future Rust version: literally never + --> $DIR/staged-deprecation-in-future.rs:17:13 + | +LL | let _ = S2; + | ^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/deprecation/suggestion.fixed b/src/test/ui/deprecation/suggestion.fixed new file mode 100644 index 000000000..d9fa2b56e --- /dev/null +++ b/src/test/ui/deprecation/suggestion.fixed @@ -0,0 +1,43 @@ +// run-rustfix + +#![feature(staged_api)] +#![feature(deprecated_suggestion)] + +#![stable(since = "1.0.0", feature = "test")] + +#![deny(deprecated)] +#![allow(dead_code)] + +struct Foo; + +impl Foo { + #[deprecated( + since = "1.0.0", + note = "replaced by `replacement`", + suggestion = "replacement", + )] + #[stable(since = "1.0.0", feature = "test")] + fn deprecated(&self) {} + + fn replacement(&self) {} +} + +mod bar { + #[deprecated( + since = "1.0.0", + note = "replaced by `replacement`", + suggestion = "replacement", + )] + #[stable(since = "1.0.0", feature = "test")] + pub fn deprecated() {} + + pub fn replacement() {} +} + +fn main() { + let foo = Foo; + + foo.replacement(); //~ ERROR use of deprecated + + bar::replacement(); //~ ERROR use of deprecated +} diff --git a/src/test/ui/deprecation/suggestion.rs b/src/test/ui/deprecation/suggestion.rs new file mode 100644 index 000000000..9dc2eaf25 --- /dev/null +++ b/src/test/ui/deprecation/suggestion.rs @@ -0,0 +1,43 @@ +// run-rustfix + +#![feature(staged_api)] +#![feature(deprecated_suggestion)] + +#![stable(since = "1.0.0", feature = "test")] + +#![deny(deprecated)] +#![allow(dead_code)] + +struct Foo; + +impl Foo { + #[deprecated( + since = "1.0.0", + note = "replaced by `replacement`", + suggestion = "replacement", + )] + #[stable(since = "1.0.0", feature = "test")] + fn deprecated(&self) {} + + fn replacement(&self) {} +} + +mod bar { + #[deprecated( + since = "1.0.0", + note = "replaced by `replacement`", + suggestion = "replacement", + )] + #[stable(since = "1.0.0", feature = "test")] + pub fn deprecated() {} + + pub fn replacement() {} +} + +fn main() { + let foo = Foo; + + foo.deprecated(); //~ ERROR use of deprecated + + bar::deprecated(); //~ ERROR use of deprecated +} diff --git a/src/test/ui/deprecation/suggestion.stderr b/src/test/ui/deprecation/suggestion.stderr new file mode 100644 index 000000000..c5f2fc091 --- /dev/null +++ b/src/test/ui/deprecation/suggestion.stderr @@ -0,0 +1,29 @@ +error: use of deprecated function `bar::deprecated`: replaced by `replacement` + --> $DIR/suggestion.rs:42:10 + | +LL | bar::deprecated(); + | ^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/suggestion.rs:8:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ +help: replace the use of the deprecated function + | +LL | bar::replacement(); + | ~~~~~~~~~~~ + +error: use of deprecated associated function `Foo::deprecated`: replaced by `replacement` + --> $DIR/suggestion.rs:40:9 + | +LL | foo.deprecated(); + | ^^^^^^^^^^ + | +help: replace the use of the deprecated associated function + | +LL | foo.replacement(); + | ~~~~~~~~~~~ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/deprecation/try-macro-suggestion.rs b/src/test/ui/deprecation/try-macro-suggestion.rs new file mode 100644 index 000000000..635ceac0b --- /dev/null +++ b/src/test/ui/deprecation/try-macro-suggestion.rs @@ -0,0 +1,9 @@ +// compile-flags: --edition 2018 +fn foo() -> Result<(), ()> { + Ok(try!()); //~ ERROR use of deprecated `try` macro + Ok(try!(Ok(()))) //~ ERROR use of deprecated `try` macro +} + +fn main() { + let _ = foo(); +} diff --git a/src/test/ui/deprecation/try-macro-suggestion.stderr b/src/test/ui/deprecation/try-macro-suggestion.stderr new file mode 100644 index 000000000..63c8a6eef --- /dev/null +++ b/src/test/ui/deprecation/try-macro-suggestion.stderr @@ -0,0 +1,31 @@ +error: use of deprecated `try` macro + --> $DIR/try-macro-suggestion.rs:3:8 + | +LL | Ok(try!()); + | ^^^^^^ + | + = note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated +help: you can still access the deprecated `try!()` macro using the "raw identifier" syntax + | +LL | Ok(r#try!()); + | ++ + +error: use of deprecated `try` macro + --> $DIR/try-macro-suggestion.rs:4:8 + | +LL | Ok(try!(Ok(()))) + | ^^^^^^^^^^^^ + | + = note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated +help: you can use the `?` operator instead + | +LL - Ok(try!(Ok(()))) +LL + Ok(Ok(())?) + | +help: alternatively, you can still access the deprecated `try!()` macro using the "raw identifier" syntax + | +LL | Ok(r#try!(Ok(()))) + | ++ + +error: aborting due to 2 previous errors + -- cgit v1.2.3