diff options
| author | Michael Goulet <michael@errs.io> | 2022-07-02 21:40:33 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-07-02 21:40:33 +0000 |
| commit | 34063199d8fc40a9e97c1409d5077b153cf32fab (patch) | |
| tree | bc7f29b36dd040186406f1287df228dd2d98fc85 /compiler/rustc_mir_transform/src | |
| parent | 750d6f85459356db4838dc06db8b19406e1ed31a (diff) | |
| download | rust-34063199d8fc40a9e97c1409d5077b153cf32fab.tar.gz rust-34063199d8fc40a9e97c1409d5077b153cf32fab.zip | |
Fix rust-call ICE in mir-inliner
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/inline.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index ce387cb4453..12f5764152e 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -180,16 +180,20 @@ impl<'tcx> Inliner<'tcx> { return Err("failed to normalize return type"); } if callsite.fn_sig.abi() == Abi::RustCall { - let mut args = args.into_iter(); - let _ = args.next(); // Skip `self` argument. - let arg_tuple_ty = args.next().unwrap().ty(&caller_body.local_decls, self.tcx); - assert!(args.next().is_none()); + let (arg_tuple, skipped_args) = match &args[..] { + [arg_tuple] => (arg_tuple, 0), + [_, arg_tuple] => (arg_tuple, 1), + _ => bug!("Expected `rust-call` to have 1 or 2 args"), + }; + let arg_tuple_ty = arg_tuple.ty(&caller_body.local_decls, self.tcx); let ty::Tuple(arg_tuple_tys) = arg_tuple_ty.kind() else { bug!("Closure arguments are not passed as a tuple"); }; - for (arg_ty, input) in arg_tuple_tys.iter().zip(callee_body.args_iter().skip(1)) { + for (arg_ty, input) in + arg_tuple_tys.iter().zip(callee_body.args_iter().skip(skipped_args)) + { let input_type = callee_body.local_decls[input].ty; if !equal_up_to_regions(self.tcx, self.param_env, arg_ty, input_type) { trace!(?arg_ty, ?input_type); |
