Goto { target } => self.go_to_block(target),
SwitchInt { ref discr, ref targets, switch_ty } => {
- let discr = self.read_immediate(self.eval_operand(discr, None)?)?;
+ let discr = self.read_immediate(&self.eval_operand(discr, None)?)?;
trace!("SwitchInt({:?})", *discr);
assert_eq!(discr.layout.ty, switch_ty);
let res = self
.overflowing_binary_op(
mir::BinOp::Eq,
- discr,
- ImmTy::from_uint(const_int, discr.layout),
+ &discr,
+ &ImmTy::from_uint(const_int, discr.layout),
)?
.0;
if res.to_bool()? {
let (fn_val, abi) = match *func.layout.ty.kind() {
ty::FnPtr(sig) => {
let caller_abi = sig.abi();
- let fn_ptr = self.read_scalar(func)?.check_init()?;
+ let fn_ptr = self.read_scalar(&func)?.check_init()?;
let fn_val = self.memory.get_fn(fn_ptr)?;
(fn_val, caller_abi)
}
),
};
let args = self.eval_operands(args)?;
+ let dest_place;
let ret = match destination {
- Some((dest, ret)) => Some((self.eval_place(dest)?, ret)),
+ Some((dest, ret)) => {
+ dest_place = self.eval_place(dest)?;
+ Some((&dest_place, ret))
+ }
None => None,
};
self.eval_fn_call(fn_val, abi, &args[..], ret, *cleanup)?;
trace!("TerminatorKind::drop: {:?}, type {}", place, ty);
let instance = Instance::resolve_drop_in_place(*self.tcx, ty);
- self.drop_in_place(place, instance, target, unwind)?;
+ self.drop_in_place(&place, instance, target, unwind)?;
}
Assert { ref cond, expected, ref msg, target, cleanup } => {
let cond_val =
- self.read_immediate(self.eval_operand(cond, None)?)?.to_scalar()?.to_bool()?;
+ self.read_immediate(&self.eval_operand(cond, None)?)?.to_scalar()?.to_bool()?;
if expected == cond_val {
self.go_to_block(target);
} else {
&mut self,
rust_abi: bool,
caller_arg: &mut impl Iterator<Item = OpTy<'tcx, M::PointerTag>>,
- callee_arg: PlaceTy<'tcx, M::PointerTag>,
+ callee_arg: &PlaceTy<'tcx, M::PointerTag>,
) -> InterpResult<'tcx> {
if rust_abi && callee_arg.layout.is_zst() {
// Nothing to do.
)
}
// We allow some transmutes here
- self.copy_op_transmute(caller_arg, callee_arg)
+ self.copy_op_transmute(&caller_arg, callee_arg)
}
/// Call this function -- pushing the stack frame and initializing the arguments.
fn_val: FnVal<'tcx, M::ExtraFnVal>,
caller_abi: Abi,
args: &[OpTy<'tcx, M::PointerTag>],
- ret: Option<(PlaceTy<'tcx, M::PointerTag>, mir::BasicBlock)>,
+ ret: Option<(&PlaceTy<'tcx, M::PointerTag>, mir::BasicBlock)>,
unwind: Option<mir::BasicBlock>,
) -> InterpResult<'tcx> {
trace!("eval_fn_call: {:#?}", fn_val);
};
if normalize_abi(caller_abi) != normalize_abi(callee_abi) {
throw_ub_format!(
- "calling a function with ABI {:?} using caller ABI {:?}",
- callee_abi,
- caller_abi
+ "calling a function with ABI {} using caller ABI {}",
+ callee_abi.name(),
+ caller_abi.name()
)
}
}
let caller_args: Cow<'_, [OpTy<'tcx, M::PointerTag>]> =
if caller_abi == Abi::RustCall && !args.is_empty() {
// Untuple
- let (&untuple_arg, args) = args.split_last().unwrap();
+ let (untuple_arg, args) = args.split_last().unwrap();
trace!("eval_fn_call: Will pass last argument by untupling");
Cow::from(
args.iter()
if Some(local) == body.spread_arg {
// Must be a tuple
for i in 0..dest.layout.fields.count() {
- let dest = self.place_field(dest, i)?;
- self.pass_argument(rust_abi, &mut caller_iter, dest)?;
+ let dest = self.place_field(&dest, i)?;
+ self.pass_argument(rust_abi, &mut caller_iter, &dest)?;
}
} else {
// Normal argument
- self.pass_argument(rust_abi, &mut caller_iter, dest)?;
+ self.pass_argument(rust_abi, &mut caller_iter, &dest)?;
}
}
// Now we should have no more caller args
let receiver_place = match args[0].layout.ty.builtin_deref(true) {
Some(_) => {
// Built-in pointer.
- self.deref_operand(args[0])?
+ self.deref_operand(&args[0])?
}
None => {
// Unsized self.
fn drop_in_place(
&mut self,
- place: PlaceTy<'tcx, M::PointerTag>,
+ place: &PlaceTy<'tcx, M::PointerTag>,
instance: ty::Instance<'tcx>,
target: mir::BasicBlock,
unwind: Option<mir::BasicBlock>,
let (instance, place) = match place.layout.ty.kind() {
ty::Dynamic(..) => {
// Dropping a trait object.
- self.unpack_dyn_trait(place)?
+ self.unpack_dyn_trait(&place)?
}
_ => (instance, place),
};
FnVal::Instance(instance),
Abi::Rust,
&[arg.into()],
- Some((dest.into(), target)),
+ Some((&dest.into(), target)),
unwind,
)
}