Skip to content

Commit fc7ffa6

Browse files
committed
Improve miri's error reporting in check_in_alloc
1 parent a54e3cc commit fc7ffa6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ pub enum CheckInAllocMsg {
3232
}
3333

3434
impl Display for CheckInAllocMsg {
35+
/// When this printed as an error the context looks like this
36+
/// "{test name} test failed: pointer must be in-bounds at offset..."
3537
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
36-
write!(f, "{}", match *self {
38+
write!(f, "{} test", match *self {
3739
CheckInAllocMsg::MemoryAccessTest => "Memory access",
3840
CheckInAllocMsg::NullPointerTest => "Null pointer",
3941
CheckInAllocMsg::PointerArithmeticTest => "Pointer arithmetic",

src/librustc/mir/interpret/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
461461
use self::InterpError::*;
462462
match *self {
463463
PointerOutOfBounds { ptr, msg, allocation_size } => {
464-
write!(f, "{} test failed: pointer must be in-bounds at offset {}, \
464+
write!(f, "{} failed: pointer must be in-bounds at offset {}, \
465465
but is outside bounds of allocation {} which has size {}",
466466
msg, ptr.offset.bytes(), ptr.alloc_id, allocation_size.bytes())
467467
},

0 commit comments

Comments
 (0)