diff options
| author | Andy Russell <arussell123@gmail.com> | 2019-03-23 21:13:57 -0400 |
|---|---|---|
| committer | Andy Russell <arussell123@gmail.com> | 2019-03-24 11:02:37 -0400 |
| commit | 8d7c2bb06a6829a96204912e5bd9e00e71195ffb (patch) | |
| tree | a6f84fa9c0b1a11769ae2782af92bc09350c407c | |
| parent | 0633c55d2030969d91b57142b8582c53101e6339 (diff) | |
| download | rust-8d7c2bb06a6829a96204912e5bd9e00e71195ffb.tar.gz rust-8d7c2bb06a6829a96204912e5bd9e00e71195ffb.zip | |
replace redundant note in deprecation warning
| -rw-r--r-- | src/librustc/middle/stability.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/deprecation/atomic_initializers.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/deprecation/suggestion.fixed | 28 | ||||
| -rw-r--r-- | src/test/ui/deprecation/suggestion.rs | 28 | ||||
| -rw-r--r-- | src/test/ui/deprecation/suggestion.stderr | 14 |
5 files changed, 72 insertions, 6 deletions
diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 72c90b25860..54e593deb32 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -576,7 +576,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { if let hir::Node::Expr(_) = self.hir().get_by_hir_id(id) { diag.span_suggestion( span, - &msg, + "replace the use of the deprecated item", suggestion.to_string(), Applicability::MachineApplicable, ); diff --git a/src/test/ui/deprecation/atomic_initializers.stderr b/src/test/ui/deprecation/atomic_initializers.stderr index 77c370814f7..b009ff9486b 100644 --- a/src/test/ui/deprecation/atomic_initializers.stderr +++ b/src/test/ui/deprecation/atomic_initializers.stderr @@ -2,11 +2,7 @@ warning: use of deprecated item 'std::sync::atomic::ATOMIC_ISIZE_INIT': the `new --> $DIR/atomic_initializers.rs:8:27 | LL | static FOO: AtomicIsize = ATOMIC_ISIZE_INIT; - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ help: replace the use of the deprecated item: `AtomicIsize::new(0)` | = note: #[warn(deprecated)] on by default -help: use of deprecated item 'std::sync::atomic::ATOMIC_ISIZE_INIT': the `new` function is now preferred - | -LL | static FOO: AtomicIsize = AtomicIsize::new(0); - | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/deprecation/suggestion.fixed b/src/test/ui/deprecation/suggestion.fixed new file mode 100644 index 00000000000..eba72f88a89 --- /dev/null +++ b/src/test/ui/deprecation/suggestion.fixed @@ -0,0 +1,28 @@ +// run-rustfix + +#![feature(staged_api)] + +#![stable(since = "1.0.0", feature = "test")] + +#![deny(deprecated)] +#![allow(dead_code)] + +struct Foo; + +impl Foo { + #[rustc_deprecated( + since = "1.0.0", + reason = "replaced by `replacement`", + suggestion = "replacement", + )] + #[stable(since = "1.0.0", feature = "test")] + fn deprecated(&self) {} + + fn replacement(&self) {} +} + +fn main() { + let foo = Foo; + + foo.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 00000000000..8f9791c13e8 --- /dev/null +++ b/src/test/ui/deprecation/suggestion.rs @@ -0,0 +1,28 @@ +// run-rustfix + +#![feature(staged_api)] + +#![stable(since = "1.0.0", feature = "test")] + +#![deny(deprecated)] +#![allow(dead_code)] + +struct Foo; + +impl Foo { + #[rustc_deprecated( + since = "1.0.0", + reason = "replaced by `replacement`", + suggestion = "replacement", + )] + #[stable(since = "1.0.0", feature = "test")] + fn deprecated(&self) {} + + fn replacement(&self) {} +} + +fn main() { + let foo = Foo; + + foo.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 00000000000..6aaabfe9575 --- /dev/null +++ b/src/test/ui/deprecation/suggestion.stderr @@ -0,0 +1,14 @@ +error: use of deprecated item 'Foo::deprecated': replaced by `replacement` + --> $DIR/suggestion.rs:27:9 + | +LL | foo.deprecated(); + | ^^^^^^^^^^ help: replace the use of the deprecated item: `replacement` + | +note: lint level defined here + --> $DIR/suggestion.rs:7:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + +error: aborting due to previous error + |
