Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace redundant note in deprecation warning #59389

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
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
varkor marked this conversation as resolved.
Show resolved Hide resolved
|
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