]> git.lizzy.rs Git - rust.git/commitdiff
note about stack-allocated variables being allocated objects
authorRalf Jung <post@ralfj.de>
Mon, 5 Aug 2019 16:41:33 +0000 (18:41 +0200)
committerRalf Jung <post@ralfj.de>
Mon, 5 Aug 2019 16:41:33 +0000 (18:41 +0200)
src/libcore/ptr/mod.rs

index 0ec4dd47b1ff017f8b0aaba6640caa9aceb2c95b..d871c12cd63dc7e26c5888c692c8e58e7c40e27f 100644 (file)
@@ -1120,7 +1120,8 @@ pub unsafe fn as_ref<'a>(self) -> Option<&'a T> {
     /// Behavior:
     ///
     /// * Both the starting and resulting pointer must be either in bounds or one
-    ///   byte past the end of the same allocated object.
+    ///   byte past the end of the same allocated object. Note that in Rust,
+    ///   every (stack-allocated) variable is considered a separate allocated object.
     ///
     /// * The computed offset, **in bytes**, cannot overflow an `isize`.
     ///
@@ -1223,7 +1224,8 @@ pub fn wrapping_offset(self, count: isize) -> *const T where T: Sized {
     /// Behavior:
     ///
     /// * Both the starting and other pointer must be either in bounds or one
-    ///   byte past the end of the same allocated object.
+    ///   byte past the end of the same allocated object. Note that in Rust,
+    ///   every (stack-allocated) variable is considered a separate allocated object.
     ///
     /// * The distance between the pointers, **in bytes**, cannot overflow an `isize`.
     ///
@@ -1338,7 +1340,8 @@ pub fn wrapping_offset_from(self, origin: *const T) -> isize where T: Sized {
     /// Behavior:
     ///
     /// * Both the starting and resulting pointer must be either in bounds or one
-    ///   byte past the end of the same allocated object.
+    ///   byte past the end of the same allocated object. Note that in Rust,
+    ///   every (stack-allocated) variable is considered a separate allocated object.
     ///
     /// * The computed offset, **in bytes**, cannot overflow an `isize`.
     ///
@@ -1395,7 +1398,8 @@ pub unsafe fn add(self, count: usize) -> Self
     /// Behavior:
     ///
     /// * Both the starting and resulting pointer must be either in bounds or one
-    ///   byte past the end of the same allocated object.
+    ///   byte past the end of the same allocated object. Note that in Rust,
+    ///   every (stack-allocated) variable is considered a separate allocated object.
     ///
     /// * The computed offset cannot exceed `isize::MAX` **bytes**.
     ///
@@ -1755,7 +1759,8 @@ pub unsafe fn as_ref<'a>(self) -> Option<&'a T> {
     /// Behavior:
     ///
     /// * Both the starting and resulting pointer must be either in bounds or one
-    ///   byte past the end of the same allocated object.
+    ///   byte past the end of the same allocated object. Note that in Rust,
+    ///   every (stack-allocated) variable is considered a separate allocated object.
     ///
     /// * The computed offset, **in bytes**, cannot overflow an `isize`.
     ///
@@ -1901,7 +1906,8 @@ pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T> {
     /// Behavior:
     ///
     /// * Both the starting and other pointer must be either in bounds or one
-    ///   byte past the end of the same allocated object.
+    ///   byte past the end of the same allocated object. Note that in Rust,
+    ///   every (stack-allocated) variable is considered a separate allocated object.
     ///
     /// * The distance between the pointers, **in bytes**, cannot overflow an `isize`.
     ///
@@ -2005,7 +2011,8 @@ pub fn wrapping_offset_from(self, origin: *const T) -> isize where T: Sized {
     /// Behavior:
     ///
     /// * Both the starting and resulting pointer must be either in bounds or one
-    ///   byte past the end of the same allocated object.
+    ///   byte past the end of the same allocated object. Note that in Rust,
+    ///   every (stack-allocated) variable is considered a separate allocated object.
     ///
     /// * The computed offset, **in bytes**, cannot overflow an `isize`.
     ///
@@ -2062,7 +2069,8 @@ pub unsafe fn add(self, count: usize) -> Self
     /// Behavior:
     ///
     /// * Both the starting and resulting pointer must be either in bounds or one
-    ///   byte past the end of the same allocated object.
+    ///   byte past the end of the same allocated object. Note that in Rust,
+    ///   every (stack-allocated) variable is considered a separate allocated object.
     ///
     /// * The computed offset cannot exceed `isize::MAX` **bytes**.
     ///