@@ -128,6 +128,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
128128 Attribute :: Parsed ( AttributeKind :: Inline ( kind, attr_span) ) => {
129129 self . check_inline ( hir_id, * attr_span, span, kind, target)
130130 }
131+ Attribute :: Parsed ( AttributeKind :: Optimize ( _, attr_span) ) => {
132+ self . check_optimize ( hir_id, * attr_span, span, target)
133+ }
131134 Attribute :: Parsed ( AttributeKind :: AllowInternalUnstable ( syms) ) => self
132135 . check_allow_internal_unstable (
133136 hir_id,
@@ -145,7 +148,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
145148 self . check_diagnostic_on_unimplemented ( attr. span ( ) , hir_id, target)
146149 }
147150 [ sym:: coverage, ..] => self . check_coverage ( attr, span, target) ,
148- [ sym:: optimize, ..] => self . check_optimize ( hir_id, attr, span, target) ,
149151 [ sym:: no_sanitize, ..] => {
150152 self . check_no_sanitize ( attr, span, target)
151153 }
@@ -515,7 +517,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
515517
516518 /// Checks that `#[optimize(..)]` is applied to a function/closure/method,
517519 /// or to an impl block or module.
518- fn check_optimize ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
520+ fn check_optimize ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
519521 let is_valid = matches ! (
520522 target,
521523 Target :: Fn
@@ -524,7 +526,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
524526 ) ;
525527 if !is_valid {
526528 self . dcx ( ) . emit_err ( errors:: OptimizeInvalidTarget {
527- attr_span : attr . span ( ) ,
529+ attr_span,
528530 defn_span : span,
529531 on_crate : hir_id == CRATE_HIR_ID ,
530532 } ) ;
0 commit comments