Skip to content

Commit d8f8168

Browse files
committed
avoid boolean inversion
1 parent 3e61442 commit d8f8168

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/librustc_mir/interpret/memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
414414
let (size, _align) = self
415415
.get_size_and_align(ptr.alloc_id, AllocCheck::MaybeDead)
416416
.expect("alloc info with MaybeDead cannot fail");
417-
// An inbounds pointer is never null! And "inbounds" includes one-past-the-end.
418-
let inbounds = ptr.offset <= size;
419-
!inbounds
417+
// If the pointer is out-of-bounds, it may be null.
418+
// Note that one-past-the-end (offset == size) is still inbounds, and never null.
419+
ptr.offset > size
420420
}
421421
}
422422

0 commit comments

Comments
 (0)