Skip to content

Commit 26d2522

Browse files
committed
fix for Panic InterpError refactoring
1 parent 49aafad commit 26d2522

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
219219
fn assert_panic(
220220
ecx: &mut InterpCx<'mir, 'tcx, Self>,
221221
span: Span,
222-
msg: &AssertMessage<'tcx>,
222+
msg: &mir::AssertMessage<'tcx>,
223223
unwind: Option<mir::BasicBlock>,
224224
) -> InterpResult<'tcx> {
225225
ecx.assert_panic(span, msg, unwind)

src/operator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'mir, 'tcx> {
105105
let pointee_size = i64::try_from(self.layout_of(pointee_ty)?.size.bytes()).unwrap();
106106
let offset = offset
107107
.checked_mul(pointee_size)
108-
.ok_or_else(|| err_panic!(Overflow(mir::BinOp::Mul)))?;
108+
.ok_or_else(|| err_ub_format!("overflow during offset comutation for inbounds pointer arithmetic"))?;
109109
// We do this first, to rule out overflows.
110110
let offset_ptr = ptr.ptr_signed_offset(offset, self)?;
111111
// What we need to check is that starting at `min(ptr, offset_ptr)`,

src/shims/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
177177
let items = this.read_scalar(args[0])?.to_machine_usize(this)?;
178178
let len = this.read_scalar(args[1])?.to_machine_usize(this)?;
179179
let size =
180-
items.checked_mul(len).ok_or_else(|| err_panic!(Overflow(mir::BinOp::Mul)))?;
180+
items.checked_mul(len).ok_or_else(|| err_ub_format!("overflow during calloc size computation"))?;
181181
let res = this.malloc(size, /*zero_init:*/ true, MiriMemoryKind::C);
182182
this.write_scalar(res, dest)?;
183183
}

src/shims/panic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
153153
fn assert_panic(
154154
&mut self,
155155
span: Span,
156-
msg: &AssertMessage<'tcx>,
156+
msg: &mir::AssertMessage<'tcx>,
157157
unwind: Option<mir::BasicBlock>,
158158
) -> InterpResult<'tcx> {
159-
use rustc::mir::interpret::PanicInfo::*;
159+
use rustc::mir::AssertKind::*;
160160
let this = self.eval_context_mut();
161161

162162
match msg {

0 commit comments

Comments
 (0)