replace redundant note in deprecation warning
This commit is contained in:
parent
0633c55d20
commit
8d7c2bb06a
5 changed files with 72 additions and 6 deletions
|
@ -576,7 +576,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
if let hir::Node::Expr(_) = self.hir().get_by_hir_id(id) {
|
if let hir::Node::Expr(_) = self.hir().get_by_hir_id(id) {
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
span,
|
span,
|
||||||
&msg,
|
"replace the use of the deprecated item",
|
||||||
suggestion.to_string(),
|
suggestion.to_string(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,11 +2,7 @@ warning: use of deprecated item 'std::sync::atomic::ATOMIC_ISIZE_INIT': the `new
|
||||||
--> $DIR/atomic_initializers.rs:8:27
|
--> $DIR/atomic_initializers.rs:8:27
|
||||||
|
|
|
|
||||||
LL | static FOO: AtomicIsize = ATOMIC_ISIZE_INIT;
|
LL | static FOO: AtomicIsize = ATOMIC_ISIZE_INIT;
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^ help: replace the use of the deprecated item: `AtomicIsize::new(0)`
|
||||||
|
|
|
|
||||||
= note: #[warn(deprecated)] on by default
|
= 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
src/test/ui/deprecation/suggestion.fixed
Normal file
28
src/test/ui/deprecation/suggestion.fixed
Normal file
|
@ -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
src/test/ui/deprecation/suggestion.rs
Normal file
28
src/test/ui/deprecation/suggestion.rs
Normal file
|
@ -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
src/test/ui/deprecation/suggestion.stderr
Normal file
14
src/test/ui/deprecation/suggestion.stderr
Normal file
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue