Improve deprecation attribute diagnostic messages.

(From the PR feedback.)

Co-authored-by: Esteban Küber <esteban@kuber.com.ar>
This commit is contained in:
Mara Bos 2020-11-02 13:17:14 +01:00
parent 9fc991a0ea
commit 9c647d1021
5 changed files with 12 additions and 19 deletions

View File

@ -656,7 +656,8 @@ where
if let Some((_, span)) = &depr {
struct_span_err!(diagnostic, attr.span, E0550, "multiple deprecated attributes")
.span_note(*span, "first deprecation attribute here")
.span_label(attr.span, "repeated deprecation attribute")
.span_label(*span, "first deprecation attribute")
.emit();
break;
}

View File

@ -92,10 +92,10 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited {
self.tcx.struct_span_lint_hir(USELESS_DEPRECATED, hir_id, *span, |lint| {
lint.build("this `#[deprecated]' annotation has no effect")
.span_suggestion(
lint.build("this `#[deprecated]` annotation has no effect")
.span_suggestion_short(
*span,
"try removing the deprecation attribute",
"remove the unnecessary deprecation attribute",
String::new(),
rustc_errors::Applicability::MachineApplicable,
)

View File

@ -32,7 +32,7 @@ fn f1() { }
struct X;
#[deprecated = "hello"] //~ ERROR this `#[deprecated]' annotation has no effect
#[deprecated = "hello"] //~ ERROR this `#[deprecated]` annotation has no effect
impl Default for X {
fn default() -> Self {
X

View File

@ -44,13 +44,9 @@ error[E0550]: multiple deprecated attributes
--> $DIR/deprecation-sanity.rs:27:1
|
LL | #[deprecated(since = "a", note = "b")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: first deprecation attribute here
--> $DIR/deprecation-sanity.rs:26:1
|
| -------------------------------------- first deprecation attribute
LL | #[deprecated(since = "a", note = "b")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute
error[E0538]: multiple 'since' items
--> $DIR/deprecation-sanity.rs:30:27
@ -58,11 +54,11 @@ error[E0538]: multiple 'since' items
LL | #[deprecated(since = "a", since = "b", note = "c")]
| ^^^^^^^^^^^
error: this `#[deprecated]' annotation has no effect
error: this `#[deprecated]` annotation has no effect
--> $DIR/deprecation-sanity.rs:35:1
|
LL | #[deprecated = "hello"]
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute
|
= note: `#[deny(useless_deprecated)]` on by default

View File

@ -86,13 +86,9 @@ error[E0550]: multiple deprecated attributes
--> $DIR/stability-attribute-sanity.rs:62:1
|
LL | #[rustc_deprecated(since = "b", reason = "text")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: first deprecation attribute here
--> $DIR/stability-attribute-sanity.rs:61:1
|
| ------------------------------------------------- first deprecation attribute
LL | #[rustc_deprecated(since = "b", reason = "text")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute
error[E0544]: multiple stability levels
--> $DIR/stability-attribute-sanity.rs:64:1