@@ -17,6 +17,15 @@ use super::{
17
17
} ;
18
18
use crate :: fluent_generated as fluent;
19
19
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
+
20
29
impl < ' mir , ' tcx : ' mir , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
21
30
pub ( super ) fn eval_terminator (
22
31
& mut self ,
@@ -68,8 +77,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
68
77
let old_stack = self . frame_idx ( ) ;
69
78
let old_loc = self . frame ( ) . loc ;
70
79
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) ?;
73
82
74
83
let destination = self . eval_place ( destination) ?;
75
84
self . eval_fn_call (
@@ -91,8 +100,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
91
100
TailCall { ref func, ref args, fn_span : _ } => {
92
101
let old_frame_idx = self . frame_idx ( ) ;
93
102
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) ?;
96
105
97
106
// This is the "canonical" implementation of tails calls,
98
107
// 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> {
347
356
}
348
357
349
358
/// 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 (
352
361
& self ,
353
362
terminator : & mir:: Terminator < ' tcx > ,
354
363
func : & mir:: Operand < ' tcx > ,
355
364
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 > > {
366
366
let func = self . eval_operand ( func, None ) ?;
367
367
let args = self . eval_operands ( args) ?;
368
368
@@ -393,7 +393,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
393
393
) ,
394
394
} ;
395
395
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 } )
397
397
}
398
398
399
399
/// Call this function -- pushing the stack frame and initializing the arguments.
0 commit comments