diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index 84733f9af6d..bc2dbfcbf38 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -32,8 +32,10 @@ pub enum CheckInAllocMsg { } impl Display for CheckInAllocMsg { + /// When this printed as an error the context looks like this + /// "{test name} test failed: pointer must be in-bounds at offset..." fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", match *self { + write!(f, "{} test", match *self { CheckInAllocMsg::MemoryAccessTest => "Memory access", CheckInAllocMsg::NullPointerTest => "Null pointer", CheckInAllocMsg::PointerArithmeticTest => "Pointer arithmetic", diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index cf2d12b5935..ce281cf0d34 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -461,7 +461,7 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> { use self::InterpError::*; match *self { PointerOutOfBounds { ptr, msg, allocation_size } => { - write!(f, "{} test failed: pointer must be in-bounds at offset {}, \ + write!(f, "{} failed: pointer must be in-bounds at offset {}, \ but is outside bounds of allocation {} which has size {}", msg, ptr.offset.bytes(), ptr.alloc_id, allocation_size.bytes()) },