Skip to content

Commit 406bd6b

Browse files
committed
prepare_fn_for_calleval_callee_and_args, +EvaluatedCalleeAndArgs
Small refactor required by review.
1 parent 6d1e2d8 commit 406bd6b

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

compiler/rustc_const_eval/src/interpret/terminator.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ use super::{
1717
};
1818
use crate::fluent_generated as fluent;
1919

20+
struct EvaluatedCalleeAndArgs<'tcx, 'mir, M: Machine<'mir, 'tcx>> {
21+
fn_val: FnVal<'tcx, M::ExtraFnVal>,
22+
args: Vec<OpTy<'tcx, M::Provenance>>,
23+
fn_sig: ty::FnSig<'tcx>,
24+
fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
25+
/// True if the function is marked as `#[track_caller]` ([`ty::InstanceDef::requires_caller_location`])
26+
with_caller_location: bool,
27+
}
28+
2029
impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
2130
pub(super) fn eval_terminator(
2231
&mut self,
@@ -68,8 +77,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
6877
let old_stack = self.frame_idx();
6978
let old_loc = self.frame().loc;
7079

71-
let (fn_val, args, fn_sig, fn_abi, with_caller_location) =
72-
self.prepare_fn_for_call(terminator, func, args)?;
80+
let EvaluatedCalleeAndArgs { fn_val, args, fn_sig, fn_abi, with_caller_location } =
81+
self.eval_callee_and_args(terminator, func, args)?;
7382

7483
let destination = self.eval_place(destination)?;
7584
self.eval_fn_call(
@@ -91,8 +100,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
91100
TailCall { ref func, ref args, fn_span: _ } => {
92101
let old_frame_idx = self.frame_idx();
93102

94-
let (fn_val, args, fn_sig, fn_abi, with_caller_location) =
95-
self.prepare_fn_for_call(terminator, func, args)?;
103+
let EvaluatedCalleeAndArgs { fn_val, args, fn_sig, fn_abi, with_caller_location } =
104+
self.eval_callee_and_args(terminator, func, args)?;
96105

97106
// This is the "canonical" implementation of tails calls,
98107
// a pop of the current stack frame, followed by a normal call
@@ -347,22 +356,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
347356
}
348357

349358
/// Shared part of `Call` and `TailCall` implementation — finding and evaluating all the
350-
/// necessary information about callee to make a call.
351-
fn prepare_fn_for_call(
359+
/// necessary information about callee and arguments to make a call.
360+
fn eval_callee_and_args(
352361
&self,
353362
terminator: &mir::Terminator<'tcx>,
354363
func: &mir::Operand<'tcx>,
355364
args: &[mir::Operand<'tcx>],
356-
) -> InterpResult<
357-
'tcx,
358-
(
359-
FnVal<'tcx, M::ExtraFnVal>,
360-
Vec<OpTy<'tcx, M::Provenance>>,
361-
ty::FnSig<'tcx>,
362-
&'tcx FnAbi<'tcx, Ty<'tcx>>,
363-
bool,
364-
),
365-
> {
365+
) -> InterpResult<'tcx, EvaluatedCalleeAndArgs<'tcx, 'mir, M>> {
366366
let func = self.eval_operand(func, None)?;
367367
let args = self.eval_operands(args)?;
368368

@@ -393,7 +393,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
393393
),
394394
};
395395

396-
Ok((fn_val, args, fn_sig, fn_abi, with_caller_location))
396+
Ok(EvaluatedCalleeAndArgs { fn_val, args, fn_sig, fn_abi, with_caller_location })
397397
}
398398

399399
/// Call this function -- pushing the stack frame and initializing the arguments.

0 commit comments

Comments
 (0)