Skip to content

Commit

Permalink
Rollup merge of rust-lang#98665 - ChrisDenton:deprecated-suggestion, …
Browse files Browse the repository at this point in the history
…r=compiler-errors

Use verbose help for deprecation suggestion

Fixes rust-lang#98631

r? `@compiler-errors`
  • Loading branch information
matthiaskrgr authored Jun 29, 2022
2 parents bba00b5 + 3cbf864 commit d708bc4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub fn deprecation_suggestion(
span: Span,
) {
if let Some(suggestion) = suggestion {
diag.span_suggestion(
diag.span_suggestion_verbose(
span,
&format!("replace the use of the deprecated {}", kind),
suggestion,
Expand Down
6 changes: 5 additions & 1 deletion src/test/ui/deprecation/atomic_initializers.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ warning: use of deprecated constant `std::sync::atomic::ATOMIC_ISIZE_INIT`: the
--> $DIR/atomic_initializers.rs:8:27
|
LL | static FOO: AtomicIsize = ATOMIC_ISIZE_INIT;
| ^^^^^^^^^^^^^^^^^ help: replace the use of the deprecated constant: `AtomicIsize::new(0)`
| ^^^^^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
help: replace the use of the deprecated constant
|
LL | static FOO: AtomicIsize = AtomicIsize::new(0);
| ~~~~~~~~~~~~~~~~~~~

warning: 1 warning emitted

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,28 @@ error: use of deprecated associated function `core::str::<impl str>::trim_left`:
--> $DIR/issue-84637-deprecated-associated-function.rs:6:21
|
LL | let _foo = str::trim_left(" aoeu");
| ^^^^^^^^^ help: replace the use of the deprecated associated function: `trim_start`
| ^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/issue-84637-deprecated-associated-function.rs:3:9
|
LL | #![deny(deprecated)]
| ^^^^^^^^^^
help: replace the use of the deprecated associated function
|
LL | let _foo = str::trim_start(" aoeu");
| ~~~~~~~~~~

error: use of deprecated associated function `core::str::<impl str>::trim_left`: superseded by `trim_start`
--> $DIR/issue-84637-deprecated-associated-function.rs:8:26
|
LL | let _bar = " aoeu".trim_left();
| ^^^^^^^^^ help: replace the use of the deprecated associated function: `trim_start`
| ^^^^^^^^^
|
help: replace the use of the deprecated associated function
|
LL | let _bar = " aoeu".trim_start();
| ~~~~~~~~~~

error: aborting due to 2 previous errors

13 changes: 11 additions & 2 deletions src/test/ui/deprecation/suggestion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,28 @@ error: use of deprecated function `bar::deprecated`: replaced by `replacement`
--> $DIR/suggestion.rs:42:10
|
LL | bar::deprecated();
| ^^^^^^^^^^ help: replace the use of the deprecated function: `replacement`
| ^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/suggestion.rs:8:9
|
LL | #![deny(deprecated)]
| ^^^^^^^^^^
help: replace the use of the deprecated function
|
LL | bar::replacement();
| ~~~~~~~~~~~

error: use of deprecated associated function `Foo::deprecated`: replaced by `replacement`
--> $DIR/suggestion.rs:40:9
|
LL | foo.deprecated();
| ^^^^^^^^^^ help: replace the use of the deprecated associated function: `replacement`
| ^^^^^^^^^^
|
help: replace the use of the deprecated associated function
|
LL | foo.replacement();
| ~~~~~~~~~~~

error: aborting due to 2 previous errors

0 comments on commit d708bc4

Please sign in to comment.