@@ -147,6 +147,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
147147 | AttributeKind :: ConstStabilityIndirect
148148 | AttributeKind :: MacroTransparency ( _) ,
149149 ) => { /* do nothing */ }
150+ Attribute :: Parsed ( AttributeKind :: AsPtr ( attr_span) ) => {
151+ self . check_applied_to_fn_or_method ( hir_id, * attr_span, span, target)
152+ }
150153 Attribute :: Unparsed ( _) => {
151154 match attr. path ( ) . as_slice ( ) {
152155 [ sym:: diagnostic, sym:: do_not_recommend, ..] => {
@@ -188,26 +191,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
188191 self . check_rustc_std_internal_symbol ( attr, span, target)
189192 }
190193 [ 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- }
194194 [ 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)
196196 }
197197 [ 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)
199199 }
200200 [ sym:: rustc_legacy_const_generics, ..] => {
201201 self . check_rustc_legacy_const_generics ( hir_id, attr, span, target, item)
202202 }
203203 [ 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)
205205 }
206206 [ 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)
208208 }
209209 [ 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)
211211 }
212212 [ sym:: rustc_lint_opt_ty, ..] => self . check_rustc_lint_opt_ty ( attr, span, target) ,
213213 [ sym:: rustc_lint_opt_deny_field_access, ..] => {
@@ -1825,15 +1825,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
18251825 fn check_applied_to_fn_or_method (
18261826 & self ,
18271827 hir_id : HirId ,
1828- attr : & Attribute ,
1829- span : Span ,
1828+ attr_span : Span ,
1829+ defn_span : Span ,
18301830 target : Target ,
18311831 ) {
18321832 let is_function = matches ! ( target, Target :: Fn | Target :: Method ( ..) ) ;
18331833 if !is_function {
18341834 self . dcx ( ) . emit_err ( errors:: AttrShouldBeAppliedToFn {
1835- attr_span : attr . span ( ) ,
1836- defn_span : span ,
1835+ attr_span,
1836+ defn_span,
18371837 on_crate : hir_id == CRATE_HIR_ID ,
18381838 } ) ;
18391839 }
0 commit comments