Skip to content

Commit a54e3cc

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

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
228228
// FIXME: Working around https://github.com/rust-lang/rust/issues/56209
229229
where Extra: AllocationExtra<Tag, MemoryExtra>
230230
{
231-
self.get_bytes_internal(cx, ptr, size, true, CheckInAllocMsg::MemoryAccess)
231+
self.get_bytes_internal(cx, ptr, size, true, CheckInAllocMsg::MemoryAccessTest)
232232
}
233233

234234
/// It is the caller's responsibility to handle undefined and pointer bytes.
@@ -243,7 +243,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
243243
// FIXME: Working around https://github.com/rust-lang/rust/issues/56209
244244
where Extra: AllocationExtra<Tag, MemoryExtra>
245245
{
246-
self.get_bytes_internal(cx, ptr, size, false, CheckInAllocMsg::MemoryAccess)
246+
self.get_bytes_internal(cx, ptr, size, false, CheckInAllocMsg::MemoryAccessTest)
247247
}
248248

249249
/// Just calling this already marks everything as defined and removes relocations,
@@ -258,7 +258,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
258258
where Extra: AllocationExtra<Tag, MemoryExtra>
259259
{
260260
assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`");
261-
self.check_bounds(cx, ptr, size, CheckInAllocMsg::MemoryAccess)?;
261+
self.check_bounds(cx, ptr, size, CheckInAllocMsg::MemoryAccessTest)?;
262262

263263
self.mark_definedness(ptr, size, true)?;
264264
self.clear_relocations(cx, ptr, size)?;

src/librustc/mir/interpret/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,9 @@ 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 {}, but is outside bounds of \
465-
allocation {} which has size {}", msg,
466-
ptr.offset.bytes(), ptr.alloc_id, allocation_size.bytes())
464+
write!(f, "{} test failed: pointer must be in-bounds at offset {}, \
465+
but is outside bounds of allocation {} which has size {}",
466+
msg, ptr.offset.bytes(), ptr.alloc_id, allocation_size.bytes())
467467
},
468468
ValidationFailure(ref err) => {
469469
write!(f, "type validation failed: {}", err)

0 commit comments

Comments
 (0)