Skip to content

Commit e4c39e1

Browse files
committed
better name for check_in_alloc
1 parent 3677c5b commit e4c39e1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/librustc/mir/interpret/pointer.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ impl<'tcx, Tag> Pointer<Tag> {
191191
Pointer { alloc_id: self.alloc_id, offset: self.offset, tag: () }
192192
}
193193

194+
/// Test if the pointer is "inbounds" of an allocation of the given size.
195+
/// A pointer is "inbounds" even if its offset is equal to the size; this is
196+
/// a "one-past-the-end" pointer.
194197
#[inline(always)]
195-
pub fn check_in_alloc(
198+
pub fn check_inbounds_alloc(
196199
self,
197200
allocation_size: Size,
198201
msg: CheckInAllocMsg,

src/librustc_mir/interpret/memory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
357357
// It is sufficient to check this for the end pointer. The addition
358358
// checks for overflow.
359359
let end_ptr = ptr.offset(size, self)?;
360-
end_ptr.check_in_alloc(allocation_size, CheckInAllocMsg::MemoryAccessTest)?;
360+
end_ptr.check_inbounds_alloc(allocation_size, CheckInAllocMsg::MemoryAccessTest)?;
361361
// Test align. Check this last; if both bounds and alignment are violated
362362
// we want the error to be about the bounds.
363363
if alloc_align.bytes() < align.bytes() {
@@ -387,7 +387,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
387387
) -> bool {
388388
let (size, _align) = self.get_size_and_align(ptr.alloc_id, AllocCheck::MaybeDead)
389389
.expect("alloc info with MaybeDead cannot fail");
390-
ptr.check_in_alloc(size, CheckInAllocMsg::NullPointerTest).is_err()
390+
ptr.check_inbounds_alloc(size, CheckInAllocMsg::NullPointerTest).is_err()
391391
}
392392
}
393393

0 commit comments

Comments
 (0)