@@ -180,16 +180,20 @@ impl<'tcx> Inliner<'tcx> {
180180 return Err ( "failed to normalize return type" ) ;
181181 }
182182 if callsite. fn_sig . abi ( ) == Abi :: RustCall {
183- let mut args = args. into_iter ( ) ;
184- let _ = args. next ( ) ; // Skip `self` argument.
185- let arg_tuple_ty = args. next ( ) . unwrap ( ) . ty ( & caller_body. local_decls , self . tcx ) ;
186- assert ! ( args. next( ) . is_none( ) ) ;
183+ let ( arg_tuple, skipped_args) = match & args[ ..] {
184+ [ arg_tuple] => ( arg_tuple, 0 ) ,
185+ [ _, arg_tuple] => ( arg_tuple, 1 ) ,
186+ _ => bug ! ( "Expected `rust-call` to have 1 or 2 args" ) ,
187+ } ;
187188
189+ let arg_tuple_ty = arg_tuple. ty ( & caller_body. local_decls , self . tcx ) ;
188190 let ty:: Tuple ( arg_tuple_tys) = arg_tuple_ty. kind ( ) else {
189191 bug ! ( "Closure arguments are not passed as a tuple" ) ;
190192 } ;
191193
192- for ( arg_ty, input) in arg_tuple_tys. iter ( ) . zip ( callee_body. args_iter ( ) . skip ( 1 ) ) {
194+ for ( arg_ty, input) in
195+ arg_tuple_tys. iter ( ) . zip ( callee_body. args_iter ( ) . skip ( skipped_args) )
196+ {
193197 let input_type = callee_body. local_decls [ input] . ty ;
194198 if !equal_up_to_regions ( self . tcx , self . param_env , arg_ty, input_type) {
195199 trace ! ( ?arg_ty, ?input_type) ;
0 commit comments