@@ -85,14 +85,22 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
8585 did_error = self . forbid_staged_api_attrs ( hir_id, attrs, inherit_deprecation. clone ( ) ) ;
8686 }
8787
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) } ;
9089 let mut is_deprecated = false ;
91- if let Some ( depr) = & depr {
90+ if let Some ( ( depr, span ) ) = & depr {
9291 is_deprecated = true ;
9392
9493 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 ( ) ;
96104 }
97105
98106 // `Deprecation` is just two pointers, no need to intern it
@@ -116,7 +124,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
116124 }
117125 } else {
118126 self . recurse_with_stability_attrs (
119- depr. map ( |d | DeprecationEntry :: local ( d, hir_id) ) ,
127+ depr. map ( |( d , _ ) | DeprecationEntry :: local ( d, hir_id) ) ,
120128 None ,
121129 None ,
122130 visit_children,
@@ -141,11 +149,11 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
141149 }
142150 }
143151
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 {
145153 if stab. is_none ( ) {
146154 struct_span_err ! (
147155 self . tcx. sess,
148- item_sp ,
156+ * span ,
149157 E0549 ,
150158 "rustc_deprecated attribute must be paired with \
151159 either stable or unstable attribute"
@@ -168,7 +176,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
168176 // Check if deprecated_since < stable_since. If it is,
169177 // this is *almost surely* an accident.
170178 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 )
172180 {
173181 // Explicit version of iter::order::lt to handle parse errors properly
174182 for ( dep_v, stab_v) in
@@ -214,7 +222,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
214222 }
215223
216224 self . recurse_with_stability_attrs (
217- depr. map ( |d | DeprecationEntry :: local ( d, hir_id) ) ,
225+ depr. map ( |( d , _ ) | DeprecationEntry :: local ( d, hir_id) ) ,
218226 stab,
219227 const_stab,
220228 visit_children,
0 commit comments