Skip to content

Commit 95e7a50

Browse files
authored
Rollup merge of #59389 - euclio:deprecated-suggestion, r=varkor
replace redundant note in deprecation warning
2 parents e298691 + 8d7c2bb commit 95e7a50

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
582582
if let hir::Node::Expr(_) = self.hir().get_by_hir_id(id) {
583583
diag.span_suggestion(
584584
span,
585-
&msg,
585+
"replace the use of the deprecated item",
586586
suggestion.to_string(),
587587
Applicability::MachineApplicable,
588588
);

src/test/ui/deprecation/atomic_initializers.stderr

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ warning: use of deprecated item 'std::sync::atomic::ATOMIC_ISIZE_INIT': the `new
22
--> $DIR/atomic_initializers.rs:8:27
33
|
44
LL | static FOO: AtomicIsize = ATOMIC_ISIZE_INIT;
5-
| ^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^ help: replace the use of the deprecated item: `AtomicIsize::new(0)`
66
|
77
= note: #[warn(deprecated)] on by default
8-
help: use of deprecated item 'std::sync::atomic::ATOMIC_ISIZE_INIT': the `new` function is now preferred
9-
|
10-
LL | static FOO: AtomicIsize = AtomicIsize::new(0);
11-
| ^^^^^^^^^^^^^^^^^^^
128

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// run-rustfix
2+
3+
#![feature(staged_api)]
4+
5+
#![stable(since = "1.0.0", feature = "test")]
6+
7+
#![deny(deprecated)]
8+
#![allow(dead_code)]
9+
10+
struct Foo;
11+
12+
impl Foo {
13+
#[rustc_deprecated(
14+
since = "1.0.0",
15+
reason = "replaced by `replacement`",
16+
suggestion = "replacement",
17+
)]
18+
#[stable(since = "1.0.0", feature = "test")]
19+
fn deprecated(&self) {}
20+
21+
fn replacement(&self) {}
22+
}
23+
24+
fn main() {
25+
let foo = Foo;
26+
27+
foo.replacement(); //~ ERROR use of deprecated
28+
}

src/test/ui/deprecation/suggestion.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// run-rustfix
2+
3+
#![feature(staged_api)]
4+
5+
#![stable(since = "1.0.0", feature = "test")]
6+
7+
#![deny(deprecated)]
8+
#![allow(dead_code)]
9+
10+
struct Foo;
11+
12+
impl Foo {
13+
#[rustc_deprecated(
14+
since = "1.0.0",
15+
reason = "replaced by `replacement`",
16+
suggestion = "replacement",
17+
)]
18+
#[stable(since = "1.0.0", feature = "test")]
19+
fn deprecated(&self) {}
20+
21+
fn replacement(&self) {}
22+
}
23+
24+
fn main() {
25+
let foo = Foo;
26+
27+
foo.deprecated(); //~ ERROR use of deprecated
28+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: use of deprecated item 'Foo::deprecated': replaced by `replacement`
2+
--> $DIR/suggestion.rs:27:9
3+
|
4+
LL | foo.deprecated();
5+
| ^^^^^^^^^^ help: replace the use of the deprecated item: `replacement`
6+
|
7+
note: lint level defined here
8+
--> $DIR/suggestion.rs:7:9
9+
|
10+
LL | #![deny(deprecated)]
11+
| ^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+

0 commit comments

Comments
 (0)