@@ -180,16 +180,20 @@ impl<'tcx> Inliner<'tcx> {
180
180
return Err ( "failed to normalize return type" ) ;
181
181
}
182
182
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
+ } ;
187
188
189
+ let arg_tuple_ty = arg_tuple. ty ( & caller_body. local_decls , self . tcx ) ;
188
190
let ty:: Tuple ( arg_tuple_tys) = arg_tuple_ty. kind ( ) else {
189
191
bug ! ( "Closure arguments are not passed as a tuple" ) ;
190
192
} ;
191
193
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
+ {
193
197
let input_type = callee_body. local_decls [ input] . ty ;
194
198
if !equal_up_to_regions ( self . tcx , self . param_env , arg_ty, input_type) {
195
199
trace ! ( ?arg_ty, ?input_type) ;
0 commit comments