@@ -606,14 +606,14 @@ fn try_inlining<'tcx, I: Inliner<'tcx>>(
606
606
ty:: EarlyBinder :: bind ( callee_body. clone ( ) ) ,
607
607
) else {
608
608
debug ! ( "failed to normalize callee body" ) ;
609
- return Err ( "implementation limitation" ) ;
609
+ return Err ( "implementation limitation -- could not normalize callee body " ) ;
610
610
} ;
611
611
612
612
// Normally, this shouldn't be required, but trait normalization failure can create a
613
613
// validation ICE.
614
614
if !validate_types ( tcx, inliner. typing_env ( ) , & callee_body, & caller_body) . is_empty ( ) {
615
615
debug ! ( "failed to validate callee body" ) ;
616
- return Err ( "implementation limitation" ) ;
616
+ return Err ( "implementation limitation -- callee body failed validation " ) ;
617
617
}
618
618
619
619
// Check call signature compatibility.
@@ -622,17 +622,9 @@ fn try_inlining<'tcx, I: Inliner<'tcx>>(
622
622
let output_type = callee_body. return_ty ( ) ;
623
623
if !util:: sub_types ( tcx, inliner. typing_env ( ) , output_type, destination_ty) {
624
624
trace ! ( ?output_type, ?destination_ty) ;
625
- debug ! ( "failed to normalize return type" ) ;
626
- return Err ( "implementation limitation" ) ;
625
+ return Err ( "implementation limitation -- return type mismatch" ) ;
627
626
}
628
627
if callsite. fn_sig . abi ( ) == ExternAbi :: RustCall {
629
- // FIXME: Don't inline user-written `extern "rust-call"` functions,
630
- // since this is generally perf-negative on rustc, and we hope that
631
- // LLVM will inline these functions instead.
632
- if callee_body. spread_arg . is_some ( ) {
633
- return Err ( "user-written rust-call functions" ) ;
634
- }
635
-
636
628
let ( self_arg, arg_tuple) = match & args[ ..] {
637
629
[ arg_tuple] => ( None , arg_tuple) ,
638
630
[ self_arg, arg_tuple] => ( Some ( self_arg) , arg_tuple) ,
@@ -642,12 +634,17 @@ fn try_inlining<'tcx, I: Inliner<'tcx>>(
642
634
let self_arg_ty = self_arg. map ( |self_arg| self_arg. node . ty ( & caller_body. local_decls , tcx) ) ;
643
635
644
636
let arg_tuple_ty = arg_tuple. node . ty ( & caller_body. local_decls , tcx) ;
645
- let ty:: Tuple ( arg_tuple_tys) = * arg_tuple_ty. kind ( ) else {
646
- bug ! ( "Closure arguments are not passed as a tuple" ) ;
637
+ let arg_tys = if callee_body. spread_arg . is_some ( ) {
638
+ std:: slice:: from_ref ( & arg_tuple_ty)
639
+ } else {
640
+ let ty:: Tuple ( arg_tuple_tys) = * arg_tuple_ty. kind ( ) else {
641
+ bug ! ( "Closure arguments are not passed as a tuple" ) ;
642
+ } ;
643
+ arg_tuple_tys. as_slice ( )
647
644
} ;
648
645
649
646
for ( arg_ty, input) in
650
- self_arg_ty. into_iter ( ) . chain ( arg_tuple_tys ) . zip ( callee_body. args_iter ( ) )
647
+ self_arg_ty. into_iter ( ) . chain ( arg_tys . iter ( ) . copied ( ) ) . zip ( callee_body. args_iter ( ) )
651
648
{
652
649
let input_type = callee_body. local_decls [ input] . ty ;
653
650
if !util:: sub_types ( tcx, inliner. typing_env ( ) , input_type, arg_ty) {
@@ -663,7 +660,7 @@ fn try_inlining<'tcx, I: Inliner<'tcx>>(
663
660
if !util:: sub_types ( tcx, inliner. typing_env ( ) , input_type, arg_ty) {
664
661
trace ! ( ?arg_ty, ?input_type) ;
665
662
debug ! ( "failed to normalize argument type" ) ;
666
- return Err ( "implementation limitation" ) ;
663
+ return Err ( "implementation limitation -- arg mismatch " ) ;
667
664
}
668
665
}
669
666
}
@@ -693,13 +690,13 @@ fn check_mir_is_available<'tcx, I: Inliner<'tcx>>(
693
690
// won't cause cycles on this.
694
691
if !inliner. tcx ( ) . is_mir_available ( callee_def_id) {
695
692
debug ! ( "item MIR unavailable" ) ;
696
- return Err ( "implementation limitation" ) ;
693
+ return Err ( "implementation limitation -- MIR unavailable " ) ;
697
694
}
698
695
}
699
696
// These have no own callable MIR.
700
697
InstanceKind :: Intrinsic ( _) | InstanceKind :: Virtual ( ..) => {
701
698
debug ! ( "instance without MIR (intrinsic / virtual)" ) ;
702
- return Err ( "implementation limitation" ) ;
699
+ return Err ( "implementation limitation -- cannot inline intrinsic " ) ;
703
700
}
704
701
705
702
// FIXME(#127030): `ConstParamHasTy` has bad interactions with
@@ -709,7 +706,7 @@ fn check_mir_is_available<'tcx, I: Inliner<'tcx>>(
709
706
// substituted.
710
707
InstanceKind :: DropGlue ( _, Some ( ty) ) if ty. has_type_flags ( TypeFlags :: HAS_CT_PARAM ) => {
711
708
debug ! ( "still needs substitution" ) ;
712
- return Err ( "implementation limitation" ) ;
709
+ return Err ( "implementation limitation -- HACK for dropping polymorphic type " ) ;
713
710
}
714
711
715
712
// This cannot result in an immediate cycle since the callee MIR is a shim, which does
@@ -1060,8 +1057,7 @@ fn make_call_args<'tcx, I: Inliner<'tcx>>(
1060
1057
1061
1058
closure_ref_arg. chain ( tuple_tmp_args) . collect ( )
1062
1059
} else {
1063
- // FIXME(edition_2024): switch back to a normal method call.
1064
- <_ >:: into_iter ( args)
1060
+ args. into_iter ( )
1065
1061
. map ( |a| create_temp_if_necessary ( inliner, a. node , callsite, caller_body, return_block) )
1066
1062
. collect ( )
1067
1063
}
0 commit comments