From: Ralf Jung Date: Thu, 13 Feb 2020 13:01:35 +0000 (+0100) Subject: fix for Panic InterpError refactoring X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=26d25220ef1e4757b167c0ddca0410d7eb20a9fa;p=rust.git fix for Panic InterpError refactoring --- diff --git a/src/machine.rs b/src/machine.rs index f8c7168a584..5d933fe8a7f 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -219,7 +219,7 @@ fn call_intrinsic( fn assert_panic( ecx: &mut InterpCx<'mir, 'tcx, Self>, span: Span, - msg: &AssertMessage<'tcx>, + msg: &mir::AssertMessage<'tcx>, unwind: Option, ) -> InterpResult<'tcx> { ecx.assert_panic(span, msg, unwind) diff --git a/src/operator.rs b/src/operator.rs index 7c932a907e7..8860b949fe9 100644 --- a/src/operator.rs +++ b/src/operator.rs @@ -105,7 +105,7 @@ fn pointer_offset_inbounds( let pointee_size = i64::try_from(self.layout_of(pointee_ty)?.size.bytes()).unwrap(); let offset = offset .checked_mul(pointee_size) - .ok_or_else(|| err_panic!(Overflow(mir::BinOp::Mul)))?; + .ok_or_else(|| err_ub_format!("overflow during offset comutation for inbounds pointer arithmetic"))?; // We do this first, to rule out overflows. let offset_ptr = ptr.ptr_signed_offset(offset, self)?; // What we need to check is that starting at `min(ptr, offset_ptr)`, diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 5b40f3c6906..4a1d62d3567 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -177,7 +177,7 @@ fn emulate_foreign_item( let items = this.read_scalar(args[0])?.to_machine_usize(this)?; let len = this.read_scalar(args[1])?.to_machine_usize(this)?; let size = - items.checked_mul(len).ok_or_else(|| err_panic!(Overflow(mir::BinOp::Mul)))?; + items.checked_mul(len).ok_or_else(|| err_ub_format!("overflow during calloc size computation"))?; let res = this.malloc(size, /*zero_init:*/ true, MiriMemoryKind::C); this.write_scalar(res, dest)?; } diff --git a/src/shims/panic.rs b/src/shims/panic.rs index d676f046465..880932ae047 100644 --- a/src/shims/panic.rs +++ b/src/shims/panic.rs @@ -153,10 +153,10 @@ fn handle_stack_pop( fn assert_panic( &mut self, span: Span, - msg: &AssertMessage<'tcx>, + msg: &mir::AssertMessage<'tcx>, unwind: Option, ) -> InterpResult<'tcx> { - use rustc::mir::interpret::PanicInfo::*; + use rustc::mir::AssertKind::*; let this = self.eval_context_mut(); match msg {