@@ -128,6 +128,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
128
128
Attribute :: Parsed ( AttributeKind :: Inline ( kind, attr_span) ) => {
129
129
self . check_inline ( hir_id, * attr_span, span, kind, target)
130
130
}
131
+ Attribute :: Parsed ( AttributeKind :: Optimize ( _, attr_span) ) => {
132
+ self . check_optimize ( hir_id, * attr_span, span, target)
133
+ }
131
134
Attribute :: Parsed ( AttributeKind :: AllowInternalUnstable ( syms) ) => self
132
135
. check_allow_internal_unstable (
133
136
hir_id,
@@ -145,7 +148,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
145
148
self . check_diagnostic_on_unimplemented ( attr. span ( ) , hir_id, target)
146
149
}
147
150
[ sym:: coverage, ..] => self . check_coverage ( attr, span, target) ,
148
- [ sym:: optimize, ..] => self . check_optimize ( hir_id, attr, span, target) ,
149
151
[ sym:: no_sanitize, ..] => {
150
152
self . check_no_sanitize ( attr, span, target)
151
153
}
@@ -515,7 +517,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
515
517
516
518
/// Checks that `#[optimize(..)]` is applied to a function/closure/method,
517
519
/// 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 ) {
519
521
let is_valid = matches ! (
520
522
target,
521
523
Target :: Fn
@@ -524,7 +526,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
524
526
) ;
525
527
if !is_valid {
526
528
self . dcx ( ) . emit_err ( errors:: OptimizeInvalidTarget {
527
- attr_span : attr . span ( ) ,
529
+ attr_span,
528
530
defn_span : span,
529
531
on_crate : hir_id == CRATE_HIR_ID ,
530
532
} ) ;
0 commit comments