@@ -523,41 +523,46 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
523
523
mixed_export_name_no_mangle_lint_state. lint_if_mixed ( tcx) ;
524
524
525
525
codegen_fn_attrs. inline = attrs. iter ( ) . fold ( InlineAttr :: None , |ia, attr| {
526
- if attr. has_name ( sym:: inline) {
527
- if attr. is_word ( ) {
528
- InlineAttr :: Hint
529
- } else if let Some ( ref items) = attr. meta_item_list ( ) {
530
- inline_span = Some ( attr. span ) ;
531
- if items. len ( ) != 1 {
532
- struct_span_code_err ! ( tcx. dcx( ) , attr. span, E0534 , "expected one argument" ) . emit ( ) ;
533
- InlineAttr :: None
534
- } else if list_contains_name ( items, sym:: always) {
535
- InlineAttr :: Always
536
- } else if list_contains_name ( items, sym:: never) {
537
- InlineAttr :: Never
538
- } else {
539
- struct_span_code_err ! ( tcx. dcx( ) , items[ 0 ] . span( ) , E0535 , "invalid argument" )
540
- . with_help ( "valid inline arguments are `always` and `never`" )
541
- . emit ( ) ;
526
+ if !attr. has_name ( sym:: inline) {
527
+ return ia;
528
+ }
542
529
543
- InlineAttr :: None
544
- }
545
- } else {
546
- ia
547
- }
548
- } else if attr. has_name ( sym:: rustc_force_inline) && tcx. features ( ) . rustc_attrs ( ) {
549
- if attr. is_word ( ) {
550
- InlineAttr :: Force { attr_span : attr. span , reason : None }
551
- } else if let Some ( val) = attr. value_str ( ) {
552
- InlineAttr :: Force { attr_span : attr. span , reason : Some ( val) }
530
+ if attr. is_word ( ) {
531
+ InlineAttr :: Hint
532
+ } else if let Some ( ref items) = attr. meta_item_list ( ) {
533
+ inline_span = Some ( attr. span ) ;
534
+ if items. len ( ) != 1 {
535
+ struct_span_code_err ! ( tcx. dcx( ) , attr. span, E0534 , "expected one argument" ) . emit ( ) ;
536
+ InlineAttr :: None
537
+ } else if list_contains_name ( items, sym:: always) {
538
+ InlineAttr :: Always
539
+ } else if list_contains_name ( items, sym:: never) {
540
+ InlineAttr :: Never
553
541
} else {
554
- debug ! ( "`rustc_force_inline` not checked by attribute validation" ) ;
555
- ia
542
+ struct_span_code_err ! ( tcx. dcx( ) , items[ 0 ] . span( ) , E0535 , "invalid argument" )
543
+ . with_help ( "valid inline arguments are `always` and `never`" )
544
+ . emit ( ) ;
545
+
546
+ InlineAttr :: None
556
547
}
557
548
} else {
558
549
ia
559
550
}
560
551
} ) ;
552
+ codegen_fn_attrs. inline = attrs. iter ( ) . fold ( codegen_fn_attrs. inline , |ia, attr| {
553
+ if !attr. has_name ( sym:: rustc_force_inline) || !tcx. features ( ) . rustc_attrs ( ) {
554
+ return ia;
555
+ }
556
+
557
+ if attr. is_word ( ) {
558
+ InlineAttr :: Force { attr_span : attr. span , reason : None }
559
+ } else if let Some ( val) = attr. value_str ( ) {
560
+ InlineAttr :: Force { attr_span : attr. span , reason : Some ( val) }
561
+ } else {
562
+ debug ! ( "`rustc_force_inline` not checked by attribute validation" ) ;
563
+ ia
564
+ }
565
+ } ) ;
561
566
562
567
// naked function MUST NOT be inlined! This attribute is required for the rust compiler itself,
563
568
// but not for the code generation backend because at that point the naked function will just be
0 commit comments