@@ -85,14 +85,22 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
85
85
did_error = self . forbid_staged_api_attrs ( hir_id, attrs, inherit_deprecation. clone ( ) ) ;
86
86
}
87
87
88
- let depr =
89
- if did_error { None } else { attr:: find_deprecation ( & self . tcx . sess , attrs, item_sp) } ;
88
+ let depr = if did_error { None } else { attr:: find_deprecation ( & self . tcx . sess , attrs) } ;
90
89
let mut is_deprecated = false ;
91
- if let Some ( depr) = & depr {
90
+ if let Some ( ( depr, span ) ) = & depr {
92
91
is_deprecated = true ;
93
92
94
93
if kind == AnnotationKind :: Prohibited || kind == AnnotationKind :: DeprecationProhibited {
95
- self . tcx . sess . span_err ( item_sp, "This deprecation annotation is useless" ) ;
94
+ self . tcx
95
+ . sess
96
+ . struct_span_err ( * span, "this deprecation annotation is useless" )
97
+ . span_suggestion (
98
+ * span,
99
+ "try removing the deprecation attribute" ,
100
+ String :: new ( ) ,
101
+ rustc_errors:: Applicability :: MachineApplicable ,
102
+ )
103
+ . emit ( ) ;
96
104
}
97
105
98
106
// `Deprecation` is just two pointers, no need to intern it
@@ -116,7 +124,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
116
124
}
117
125
} else {
118
126
self . recurse_with_stability_attrs (
119
- depr. map ( |d | DeprecationEntry :: local ( d, hir_id) ) ,
127
+ depr. map ( |( d , _ ) | DeprecationEntry :: local ( d, hir_id) ) ,
120
128
None ,
121
129
None ,
122
130
visit_children,
@@ -141,11 +149,11 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
141
149
}
142
150
}
143
151
144
- if depr . as_ref ( ) . map_or ( false , |d| d . is_since_rustc_version ) {
152
+ if let Some ( ( rustc_attr :: Deprecation { is_since_rustc_version : true , .. } , span ) ) = & depr {
145
153
if stab. is_none ( ) {
146
154
struct_span_err ! (
147
155
self . tcx. sess,
148
- item_sp ,
156
+ * span ,
149
157
E0549 ,
150
158
"rustc_deprecated attribute must be paired with \
151
159
either stable or unstable attribute"
@@ -168,7 +176,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
168
176
// Check if deprecated_since < stable_since. If it is,
169
177
// this is *almost surely* an accident.
170
178
if let ( & Some ( dep_since) , & attr:: Stable { since : stab_since } ) =
171
- ( & depr. as_ref ( ) . and_then ( |d | d. since ) , & stab. level )
179
+ ( & depr. as_ref ( ) . and_then ( |( d , _ ) | d. since ) , & stab. level )
172
180
{
173
181
// Explicit version of iter::order::lt to handle parse errors properly
174
182
for ( dep_v, stab_v) in
@@ -214,7 +222,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
214
222
}
215
223
216
224
self . recurse_with_stability_attrs (
217
- depr. map ( |d | DeprecationEntry :: local ( d, hir_id) ) ,
225
+ depr. map ( |( d , _ ) | DeprecationEntry :: local ( d, hir_id) ) ,
218
226
stab,
219
227
const_stab,
220
228
visit_children,
0 commit comments