Improve deprecation attribute diagnostic messages.
(From the PR feedback.) Co-authored-by: Esteban Küber <esteban@kuber.com.ar>
This commit is contained in:
parent
9fc991a0ea
commit
9c647d1021
5 changed files with 12 additions and 19 deletions
|
@ -656,7 +656,8 @@ where
|
||||||
|
|
||||||
if let Some((_, span)) = &depr {
|
if let Some((_, span)) = &depr {
|
||||||
struct_span_err!(diagnostic, attr.span, E0550, "multiple deprecated attributes")
|
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();
|
.emit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,10 +92,10 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
||||||
|
|
||||||
if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited {
|
if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited {
|
||||||
self.tcx.struct_span_lint_hir(USELESS_DEPRECATED, hir_id, *span, |lint| {
|
self.tcx.struct_span_lint_hir(USELESS_DEPRECATED, hir_id, *span, |lint| {
|
||||||
lint.build("this `#[deprecated]' annotation has no effect")
|
lint.build("this `#[deprecated]` annotation has no effect")
|
||||||
.span_suggestion(
|
.span_suggestion_short(
|
||||||
*span,
|
*span,
|
||||||
"try removing the deprecation attribute",
|
"remove the unnecessary deprecation attribute",
|
||||||
String::new(),
|
String::new(),
|
||||||
rustc_errors::Applicability::MachineApplicable,
|
rustc_errors::Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,7 +32,7 @@ fn f1() { }
|
||||||
|
|
||||||
struct X;
|
struct X;
|
||||||
|
|
||||||
#[deprecated = "hello"] //~ ERROR this `#[deprecated]' annotation has no effect
|
#[deprecated = "hello"] //~ ERROR this `#[deprecated]` annotation has no effect
|
||||||
impl Default for X {
|
impl Default for X {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
X
|
X
|
||||||
|
|
|
@ -44,13 +44,9 @@ error[E0550]: multiple deprecated attributes
|
||||||
--> $DIR/deprecation-sanity.rs:27:1
|
--> $DIR/deprecation-sanity.rs:27:1
|
||||||
|
|
|
|
||||||
LL | #[deprecated(since = "a", note = "b")]
|
LL | #[deprecated(since = "a", note = "b")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| -------------------------------------- first deprecation attribute
|
||||||
|
|
|
||||||
note: first deprecation attribute here
|
|
||||||
--> $DIR/deprecation-sanity.rs:26:1
|
|
||||||
|
|
|
||||||
LL | #[deprecated(since = "a", note = "b")]
|
LL | #[deprecated(since = "a", note = "b")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute
|
||||||
|
|
||||||
error[E0538]: multiple 'since' items
|
error[E0538]: multiple 'since' items
|
||||||
--> $DIR/deprecation-sanity.rs:30:27
|
--> $DIR/deprecation-sanity.rs:30:27
|
||||||
|
@ -58,11 +54,11 @@ error[E0538]: multiple 'since' items
|
||||||
LL | #[deprecated(since = "a", since = "b", note = "c")]
|
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
|
--> $DIR/deprecation-sanity.rs:35:1
|
||||||
|
|
|
|
||||||
LL | #[deprecated = "hello"]
|
LL | #[deprecated = "hello"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute
|
| ^^^^^^^^^^^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute
|
||||||
|
|
|
|
||||||
= note: `#[deny(useless_deprecated)]` on by default
|
= note: `#[deny(useless_deprecated)]` on by default
|
||||||
|
|
||||||
|
|
|
@ -86,13 +86,9 @@ error[E0550]: multiple deprecated attributes
|
||||||
--> $DIR/stability-attribute-sanity.rs:62:1
|
--> $DIR/stability-attribute-sanity.rs:62:1
|
||||||
|
|
|
|
||||||
LL | #[rustc_deprecated(since = "b", reason = "text")]
|
LL | #[rustc_deprecated(since = "b", reason = "text")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ------------------------------------------------- first deprecation attribute
|
||||||
|
|
|
||||||
note: first deprecation attribute here
|
|
||||||
--> $DIR/stability-attribute-sanity.rs:61:1
|
|
||||||
|
|
|
||||||
LL | #[rustc_deprecated(since = "b", reason = "text")]
|
LL | #[rustc_deprecated(since = "b", reason = "text")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute
|
||||||
|
|
||||||
error[E0544]: multiple stability levels
|
error[E0544]: multiple stability levels
|
||||||
--> $DIR/stability-attribute-sanity.rs:64:1
|
--> $DIR/stability-attribute-sanity.rs:64:1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue