diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index 802aa9ef4645..0ac9f3025d48 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -60,7 +60,7 @@ pub fn copy_fn_args(args: &[FnArg<'tcx, M::Provenance>]) -> Vec, field: FieldIdx, @@ -655,12 +655,17 @@ pub(super) fn init_fn_call( if caller_abi == ExternAbi::RustCall && !args.is_empty() { // Untuple let (untuple_arg, args) = args.split_last().unwrap(); + let ty::Tuple(untuple_fields) = untuple_arg.layout().ty.kind() else { + span_bug!(self.cur_span(), "untuple argument must be a tuple") + }; trace!("init_fn_call: Will pass last argument by untupling"); Cow::from( args.iter() + // The regular arguments. .map(|a| interp_ok(a.clone())) - .chain((0..untuple_arg.layout().fields.count()).map(|i| { - self.fn_arg_field(untuple_arg, FieldIdx::from_usize(i)) + // The fields of the untupled argument. + .chain((0..untuple_fields.len()).map(|i| { + self.fn_arg_project_field(untuple_arg, FieldIdx::from_usize(i)) })) .collect::>>()?, )