@@ -147,6 +147,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
147
147
| AttributeKind :: ConstStabilityIndirect
148
148
| AttributeKind :: MacroTransparency ( _) ,
149
149
) => { /* do nothing */ }
150
+ Attribute :: Parsed ( AttributeKind :: AsPtr ( attr_span) ) => {
151
+ self . check_applied_to_fn_or_method ( hir_id, * attr_span, span, target)
152
+ }
150
153
Attribute :: Unparsed ( _) => {
151
154
match attr. path ( ) . as_slice ( ) {
152
155
[ sym:: diagnostic, sym:: do_not_recommend, ..] => {
@@ -188,26 +191,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
188
191
self . check_rustc_std_internal_symbol ( attr, span, target)
189
192
}
190
193
[ sym:: naked, ..] => self . check_naked ( hir_id, attr, span, target, attrs) ,
191
- [ sym:: rustc_as_ptr, ..] => {
192
- self . check_applied_to_fn_or_method ( hir_id, attr, span, target)
193
- }
194
194
[ sym:: rustc_no_implicit_autorefs, ..] => {
195
- self . check_applied_to_fn_or_method ( hir_id, attr, span, target)
195
+ self . check_applied_to_fn_or_method ( hir_id, attr. span ( ) , span, target)
196
196
}
197
197
[ sym:: rustc_never_returns_null_ptr, ..] => {
198
- self . check_applied_to_fn_or_method ( hir_id, attr, span, target)
198
+ self . check_applied_to_fn_or_method ( hir_id, attr. span ( ) , span, target)
199
199
}
200
200
[ sym:: rustc_legacy_const_generics, ..] => {
201
201
self . check_rustc_legacy_const_generics ( hir_id, attr, span, target, item)
202
202
}
203
203
[ sym:: rustc_lint_query_instability, ..] => {
204
- self . check_applied_to_fn_or_method ( hir_id, attr, span, target)
204
+ self . check_applied_to_fn_or_method ( hir_id, attr. span ( ) , span, target)
205
205
}
206
206
[ sym:: rustc_lint_untracked_query_information, ..] => {
207
- self . check_applied_to_fn_or_method ( hir_id, attr, span, target)
207
+ self . check_applied_to_fn_or_method ( hir_id, attr. span ( ) , span, target)
208
208
}
209
209
[ sym:: rustc_lint_diagnostics, ..] => {
210
- self . check_applied_to_fn_or_method ( hir_id, attr, span, target)
210
+ self . check_applied_to_fn_or_method ( hir_id, attr. span ( ) , span, target)
211
211
}
212
212
[ sym:: rustc_lint_opt_ty, ..] => self . check_rustc_lint_opt_ty ( attr, span, target) ,
213
213
[ sym:: rustc_lint_opt_deny_field_access, ..] => {
@@ -1825,15 +1825,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1825
1825
fn check_applied_to_fn_or_method (
1826
1826
& self ,
1827
1827
hir_id : HirId ,
1828
- attr : & Attribute ,
1829
- span : Span ,
1828
+ attr_span : Span ,
1829
+ defn_span : Span ,
1830
1830
target : Target ,
1831
1831
) {
1832
1832
let is_function = matches ! ( target, Target :: Fn | Target :: Method ( ..) ) ;
1833
1833
if !is_function {
1834
1834
self . dcx ( ) . emit_err ( errors:: AttrShouldBeAppliedToFn {
1835
- attr_span : attr . span ( ) ,
1836
- defn_span : span ,
1835
+ attr_span,
1836
+ defn_span,
1837
1837
on_crate : hir_id == CRATE_HIR_ID ,
1838
1838
} ) ;
1839
1839
}
0 commit comments