Pass MPlaceTy by reference not value
This commit is contained in:
@@ -72,7 +72,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
|
||||
None => InternKind::Constant,
|
||||
}
|
||||
};
|
||||
intern_const_alloc_recursive(ecx, intern_kind, ret)?;
|
||||
intern_const_alloc_recursive(ecx, intern_kind, &ret)?;
|
||||
|
||||
debug!("eval_body_using_ecx done: {:?}", *ret);
|
||||
Ok(ret)
|
||||
@@ -137,7 +137,7 @@ pub(super) fn op_to_const<'tcx>(
|
||||
op.try_as_mplace(ecx)
|
||||
};
|
||||
|
||||
let to_const_value = |mplace: MPlaceTy<'_>| match mplace.ptr {
|
||||
let to_const_value = |mplace: &MPlaceTy<'_>| match mplace.ptr {
|
||||
Scalar::Ptr(ptr) => {
|
||||
let alloc = ecx.tcx.global_alloc(ptr.alloc_id).unwrap_memory();
|
||||
ConstValue::ByRef { alloc, offset: ptr.offset }
|
||||
@@ -155,12 +155,12 @@ pub(super) fn op_to_const<'tcx>(
|
||||
}
|
||||
};
|
||||
match immediate {
|
||||
Ok(mplace) => to_const_value(mplace),
|
||||
Ok(ref mplace) => to_const_value(mplace),
|
||||
// see comment on `let try_as_immediate` above
|
||||
Err(imm) => match *imm {
|
||||
Immediate::Scalar(x) => match x {
|
||||
ScalarMaybeUninit::Scalar(s) => ConstValue::Scalar(s),
|
||||
ScalarMaybeUninit::Uninit => to_const_value(op.assert_mem_place(ecx)),
|
||||
ScalarMaybeUninit::Uninit => to_const_value(&op.assert_mem_place(ecx)),
|
||||
},
|
||||
Immediate::ScalarPair(a, b) => {
|
||||
let (data, start) = match a.check_init().unwrap() {
|
||||
|
||||
@@ -40,7 +40,7 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
|
||||
assert!(args.len() == 1);
|
||||
|
||||
let msg_place = self.deref_operand(&args[0])?;
|
||||
let msg = Symbol::intern(self.read_str(msg_place)?);
|
||||
let msg = Symbol::intern(self.read_str(&msg_place)?);
|
||||
let span = self.find_closest_untracked_caller_location();
|
||||
let (file, line, col) = self.location_triple_for_span(span);
|
||||
Err(ConstEvalErrKind::Panic { msg, file, line, col }.into())
|
||||
|
||||
@@ -29,7 +29,7 @@ pub(crate) fn const_caller_location(
|
||||
let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), false);
|
||||
|
||||
let loc_place = ecx.alloc_caller_location(file, line, col);
|
||||
if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, loc_place).is_err() {
|
||||
if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() {
|
||||
bug!("intern_const_alloc_recursive should not error in this case")
|
||||
}
|
||||
ConstValue::Scalar(loc_place.ptr)
|
||||
|
||||
Reference in New Issue
Block a user