@@ -189,8 +189,7 @@ impl<T: ?Sized> *mut T {
189189 /// Behavior:
190190 ///
191191 /// * Both the starting and resulting pointer must be either in bounds or one
192- /// byte past the end of the same allocated object. Note that in Rust,
193- /// every (stack-allocated) variable is considered a separate allocated object.
192+ /// byte past the end of the same [allocated object].
194193 ///
195194 /// * The computed offset, **in bytes**, cannot overflow an `isize`.
196195 ///
@@ -215,6 +214,7 @@ impl<T: ?Sized> *mut T {
215214 /// enables more aggressive compiler optimizations.
216215 ///
217216 /// [`wrapping_offset`]: #method.wrapping_offset
217+ /// [allocated object]: crate::ptr#allocated-object
218218 ///
219219 /// # Examples
220220 ///
@@ -251,9 +251,8 @@ impl<T: ?Sized> *mut T {
251251 ///
252252 /// This operation itself is always safe, but using the resulting pointer is not.
253253 ///
254- /// The resulting pointer remains attached to the same allocated object that `self` points to.
255- /// It may *not* be used to access a different allocated object. Note that in Rust, every
256- /// (stack-allocated) variable is considered a separate allocated object.
254+ /// The resulting pointer "remembers" the [allocated object] that `self` points to; it may not
255+ /// be used to read or write other allocated objects.
257256 ///
258257 /// In other words, `let z = x.wrapping_offset((y as isize) - (x as isize))` does *not* make `z`
259258 /// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
@@ -271,10 +270,8 @@ impl<T: ?Sized> *mut T {
271270 /// `x.wrapping_offset(o).wrapping_offset(o.wrapping_neg())` is always the same as `x`. In other
272271 /// words, leaving the allocated object and then re-entering it later is permitted.
273272 ///
274- /// If you need to cross object boundaries, cast the pointer to an integer and
275- /// do the arithmetic there.
276- ///
277273 /// [`offset`]: #method.offset
274+ /// [allocated object]: crate::ptr#allocated-object
278275 ///
279276 /// # Examples
280277 ///
@@ -485,8 +482,7 @@ impl<T: ?Sized> *mut T {
485482 /// Behavior:
486483 ///
487484 /// * Both the starting and other pointer must be either in bounds or one
488- /// byte past the end of the same allocated object. Note that in Rust,
489- /// every (stack-allocated) variable is considered a separate allocated object.
485+ /// byte past the end of the same [allocated object].
490486 ///
491487 /// * Both pointers must be *derived from* a pointer to the same object.
492488 /// (See below for an example.)
@@ -516,6 +512,7 @@ impl<T: ?Sized> *mut T {
516512 /// such large allocations either.)
517513 ///
518514 /// [`add`]: #method.add
515+ /// [allocated object]: crate::ptr#allocated-object
519516 ///
520517 /// # Panics
521518 ///
@@ -575,8 +572,7 @@ impl<T: ?Sized> *mut T {
575572 /// Behavior:
576573 ///
577574 /// * Both the starting and resulting pointer must be either in bounds or one
578- /// byte past the end of the same allocated object. Note that in Rust,
579- /// every (stack-allocated) variable is considered a separate allocated object.
575+ /// byte past the end of the same [allocated object].
580576 ///
581577 /// * The computed offset, **in bytes**, cannot overflow an `isize`.
582578 ///
@@ -639,8 +635,7 @@ impl<T: ?Sized> *mut T {
639635 /// Behavior:
640636 ///
641637 /// * Both the starting and resulting pointer must be either in bounds or one
642- /// byte past the end of the same allocated object. Note that in Rust,
643- /// every (stack-allocated) variable is considered a separate allocated object.
638+ /// byte past the end of the same [allocated object].
644639 ///
645640 /// * The computed offset cannot exceed `isize::MAX` **bytes**.
646641 ///
@@ -665,6 +660,7 @@ impl<T: ?Sized> *mut T {
665660 /// enables more aggressive compiler optimizations.
666661 ///
667662 /// [`wrapping_sub`]: #method.wrapping_sub
663+ /// [allocated object]: crate::ptr#allocated-object
668664 ///
669665 /// # Examples
670666 ///
@@ -701,9 +697,8 @@ impl<T: ?Sized> *mut T {
701697 ///
702698 /// This operation itself is always safe, but using the resulting pointer is not.
703699 ///
704- /// The resulting pointer remains attached to the same allocated object that `self` points to.
705- /// It may *not* be used to access a different allocated object. Note that in Rust, every
706- /// (stack-allocated) variable is considered a separate allocated object.
700+ /// The resulting pointer "remembers" the [allocated object] that `self` points to; it may not
701+ /// be used to read or write other allocated objects.
707702 ///
708703 /// In other words, `let z = x.wrapping_add((y as usize) - (x as usize))` does *not* make `z`
709704 /// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
@@ -721,10 +716,8 @@ impl<T: ?Sized> *mut T {
721716 /// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
722717 /// allocated object and then re-entering it later is permitted.
723718 ///
724- /// If you need to cross object boundaries, cast the pointer to an integer and
725- /// do the arithmetic there.
726- ///
727719 /// [`add`]: #method.add
720+ /// [allocated object]: crate::ptr#allocated-object
728721 ///
729722 /// # Examples
730723 ///
@@ -766,9 +759,8 @@ impl<T: ?Sized> *mut T {
766759 ///
767760 /// This operation itself is always safe, but using the resulting pointer is not.
768761 ///
769- /// The resulting pointer remains attached to the same allocated object that `self` points to.
770- /// It may *not* be used to access a different allocated object. Note that in Rust, every
771- /// (stack-allocated) variable is considered a separate allocated object.
762+ /// The resulting pointer "remembers" the [allocated object] that `self` points to; it may not
763+ /// be used to read or write other allocated objects.
772764 ///
773765 /// In other words, `let z = x.wrapping_sub((x as usize) - (y as usize))` does *not* make `z`
774766 /// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
@@ -786,10 +778,8 @@ impl<T: ?Sized> *mut T {
786778 /// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
787779 /// allocated object and then re-entering it later is permitted.
788780 ///
789- /// If you need to cross object boundaries, cast the pointer to an integer and
790- /// do the arithmetic there.
791- ///
792781 /// [`sub`]: #method.sub
782+ /// [allocated object]: crate::ptr#allocated-object
793783 ///
794784 /// # Examples
795785 ///
@@ -1261,7 +1251,7 @@ impl<T> *mut [T] {
12611251 /// * The pointer must be [valid] for reads for `ptr.len() * mem::size_of::<T>()` many bytes,
12621252 /// and it must be properly aligned. This means in particular:
12631253 ///
1264- /// * The entire memory range of this slice must be contained within a single allocated object!
1254+ /// * The entire memory range of this slice must be contained within a single [ allocated object] !
12651255 /// Slices can never span across multiple allocated objects.
12661256 ///
12671257 /// * The pointer must be aligned even for zero-length slices. One
@@ -1283,6 +1273,7 @@ impl<T> *mut [T] {
12831273 /// See also [`slice::from_raw_parts`][].
12841274 ///
12851275 /// [valid]: crate::ptr#safety
1276+ /// [allocated object]: crate::ptr#allocated-object
12861277 #[ inline]
12871278 #[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
12881279 pub unsafe fn as_uninit_slice < ' a > ( self ) -> Option < & ' a [ MaybeUninit < T > ] > {
@@ -1311,7 +1302,7 @@ impl<T> *mut [T] {
13111302 /// * The pointer must be [valid] for reads and writes for `ptr.len() * mem::size_of::<T>()`
13121303 /// many bytes, and it must be properly aligned. This means in particular:
13131304 ///
1314- /// * The entire memory range of this slice must be contained within a single allocated object!
1305+ /// * The entire memory range of this slice must be contained within a single [ allocated object] !
13151306 /// Slices can never span across multiple allocated objects.
13161307 ///
13171308 /// * The pointer must be aligned even for zero-length slices. One
@@ -1333,6 +1324,7 @@ impl<T> *mut [T] {
13331324 /// See also [`slice::from_raw_parts_mut`][].
13341325 ///
13351326 /// [valid]: crate::ptr#safety
1327+ /// [allocated object]: crate::ptr#allocated-object
13361328 #[ inline]
13371329 #[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
13381330 pub unsafe fn as_uninit_slice_mut < ' a > ( self ) -> Option < & ' a mut [ MaybeUninit < T > ] > {
0 commit comments