]> git.lizzy.rs Git - rust.git/commitdiff
better name for check_in_alloc
authorRalf Jung <post@ralfj.de>
Sun, 28 Jul 2019 12:19:13 +0000 (14:19 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 28 Jul 2019 12:19:13 +0000 (14:19 +0200)
src/librustc/mir/interpret/pointer.rs
src/librustc_mir/interpret/memory.rs

index 0e3b8459115e30e96c325fc62adc720eac402a29..fceae75d7242149905b77a1cfef06d16630951f5 100644 (file)
@@ -191,8 +191,11 @@ pub fn erase_tag(self) -> Pointer {
         Pointer { alloc_id: self.alloc_id, offset: self.offset, tag: () }
     }
 
+    /// Test if the pointer is "inbounds" of an allocation of the given size.
+    /// A pointer is "inbounds" even if its offset is equal to the size; this is
+    /// a "one-past-the-end" pointer.
     #[inline(always)]
-    pub fn check_in_alloc(
+    pub fn check_inbounds_alloc(
         self,
         allocation_size: Size,
         msg: CheckInAllocMsg,
index 4575784ac3703ba9dd08075da9549837836eac11..ad1ec5a11ed6ceb8b678e594ad86eb841e589d53 100644 (file)
@@ -357,7 +357,7 @@ fn check_offset_align(offset: u64, align: Align) -> InterpResult<'static> {
                 // It is sufficient to check this for the end pointer. The addition
                 // checks for overflow.
                 let end_ptr = ptr.offset(size, self)?;
-                end_ptr.check_in_alloc(allocation_size, CheckInAllocMsg::MemoryAccessTest)?;
+                end_ptr.check_inbounds_alloc(allocation_size, CheckInAllocMsg::MemoryAccessTest)?;
                 // Test align. Check this last; if both bounds and alignment are violated
                 // we want the error to be about the bounds.
                 if alloc_align.bytes() < align.bytes() {
@@ -387,7 +387,7 @@ pub fn ptr_may_be_null(
     ) -> bool {
         let (size, _align) = self.get_size_and_align(ptr.alloc_id, AllocCheck::MaybeDead)
             .expect("alloc info with MaybeDead cannot fail");
-        ptr.check_in_alloc(size, CheckInAllocMsg::NullPointerTest).is_err()
+        ptr.check_inbounds_alloc(size, CheckInAllocMsg::NullPointerTest).is_err()
     }
 }