From 3cbf864d4303548e42514be6c216ba0f18acb543 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Wed, 29 Jun 2022 09:36:12 +0100 Subject: [PATCH] Use verbose help for deprecation suggestion --- compiler/rustc_middle/src/middle/stability.rs | 2 +- src/test/ui/deprecation/atomic_initializers.stderr | 6 +++++- ...ssue-84637-deprecated-associated-function.stderr | 13 +++++++++++-- src/test/ui/deprecation/suggestion.stderr | 13 +++++++++++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index d23707a9d316e..802b7852bace1 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -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, diff --git a/src/test/ui/deprecation/atomic_initializers.stderr b/src/test/ui/deprecation/atomic_initializers.stderr index eaf5c61b440bd..30fcc9de6181e 100644 --- a/src/test/ui/deprecation/atomic_initializers.stderr +++ b/src/test/ui/deprecation/atomic_initializers.stderr @@ -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 diff --git a/src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr index e65d21bb09bbe..8d4529526e370 100644 --- a/src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr +++ b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr @@ -2,19 +2,28 @@ error: use of deprecated associated function `core::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::::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 diff --git a/src/test/ui/deprecation/suggestion.stderr b/src/test/ui/deprecation/suggestion.stderr index 8d1e108345f30..c5f2fc0912514 100644 --- a/src/test/ui/deprecation/suggestion.stderr +++ b/src/test/ui/deprecation/suggestion.stderr @@ -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