Skip to content

Commit

Permalink
Rollup merge of rust-lang#59389 - euclio:deprecated-suggestion, r=varkor
Browse files Browse the repository at this point in the history
replace redundant note in deprecation warning
  • Loading branch information
Centril authored Mar 26, 2019
2 parents 8aa161b + 8d7c2bb commit e5f4755
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,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,
);
Expand Down
6 changes: 1 addition & 5 deletions src/test/ui/deprecation/atomic_initializers.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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);
| ^^^^^^^^^^^^^^^^^^^

28 changes: 28 additions & 0 deletions src/test/ui/deprecation/suggestion.fixed
Original file line number Diff line number Diff line change
@@ -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
}
28 changes: 28 additions & 0 deletions src/test/ui/deprecation/suggestion.rs
Original file line number Diff line number Diff line change
@@ -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
}
14 changes: 14 additions & 0 deletions src/test/ui/deprecation/suggestion.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e5f4755

Please sign in to comment.