@@ -189,8 +189,7 @@ impl<T: ?Sized> *mut T {
189
189
/// Behavior:
190
190
///
191
191
/// * 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].
194
193
///
195
194
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
196
195
///
@@ -215,6 +214,7 @@ impl<T: ?Sized> *mut T {
215
214
/// enables more aggressive compiler optimizations.
216
215
///
217
216
/// [`wrapping_offset`]: #method.wrapping_offset
217
+ /// [allocated object]: crate::ptr#allocated-object
218
218
///
219
219
/// # Examples
220
220
///
@@ -251,9 +251,8 @@ impl<T: ?Sized> *mut T {
251
251
///
252
252
/// This operation itself is always safe, but using the resulting pointer is not.
253
253
///
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 remains attached to the same [allocated object] that `self` points to.
255
+ /// It may *not* be used to access a different allocated object.
257
256
///
258
257
/// In other words, `let z = x.wrapping_offset((y as isize) - (x as isize))` does *not* make `z`
259
258
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
@@ -275,6 +274,7 @@ impl<T: ?Sized> *mut T {
275
274
/// do the arithmetic there.
276
275
///
277
276
/// [`offset`]: #method.offset
277
+ /// [allocated object]: crate::ptr#allocated-object
278
278
///
279
279
/// # Examples
280
280
///
@@ -485,8 +485,7 @@ impl<T: ?Sized> *mut T {
485
485
/// Behavior:
486
486
///
487
487
/// * 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.
488
+ /// byte past the end of the same [allocated object].
490
489
///
491
490
/// * Both pointers must be *derived from* a pointer to the same object.
492
491
/// (See below for an example.)
@@ -516,6 +515,7 @@ impl<T: ?Sized> *mut T {
516
515
/// such large allocations either.)
517
516
///
518
517
/// [`add`]: #method.add
518
+ /// [allocated object]: crate::ptr#allocated-object
519
519
///
520
520
/// # Panics
521
521
///
@@ -575,8 +575,7 @@ impl<T: ?Sized> *mut T {
575
575
/// Behavior:
576
576
///
577
577
/// * 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.
578
+ /// byte past the end of the same [allocated object].
580
579
///
581
580
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
582
581
///
@@ -639,8 +638,7 @@ impl<T: ?Sized> *mut T {
639
638
/// Behavior:
640
639
///
641
640
/// * 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.
641
+ /// byte past the end of the same [allocated object].
644
642
///
645
643
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
646
644
///
@@ -665,6 +663,7 @@ impl<T: ?Sized> *mut T {
665
663
/// enables more aggressive compiler optimizations.
666
664
///
667
665
/// [`wrapping_sub`]: #method.wrapping_sub
666
+ /// [allocated object]: crate::ptr#allocated-object
668
667
///
669
668
/// # Examples
670
669
///
@@ -701,9 +700,8 @@ impl<T: ?Sized> *mut T {
701
700
///
702
701
/// This operation itself is always safe, but using the resulting pointer is not.
703
702
///
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.
703
+ /// The resulting pointer remains attached to the same [allocated object] that `self` points to.
704
+ /// It may *not* be used to access a different allocated object.
707
705
///
708
706
/// In other words, `let z = x.wrapping_add((y as usize) - (x as usize))` does *not* make `z`
709
707
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
@@ -725,6 +723,7 @@ impl<T: ?Sized> *mut T {
725
723
/// do the arithmetic there.
726
724
///
727
725
/// [`add`]: #method.add
726
+ /// [allocated object]: crate::ptr#allocated-object
728
727
///
729
728
/// # Examples
730
729
///
@@ -766,9 +765,8 @@ impl<T: ?Sized> *mut T {
766
765
///
767
766
/// This operation itself is always safe, but using the resulting pointer is not.
768
767
///
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.
768
+ /// The resulting pointer remains attached to the same [allocated object] that `self` points to.
769
+ /// It may *not* be used to access a different allocated object.
772
770
///
773
771
/// In other words, `let z = x.wrapping_sub((x as usize) - (y as usize))` does *not* make `z`
774
772
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
@@ -790,6 +788,7 @@ impl<T: ?Sized> *mut T {
790
788
/// do the arithmetic there.
791
789
///
792
790
/// [`sub`]: #method.sub
791
+ /// [allocated object]: crate::ptr#allocated-object
793
792
///
794
793
/// # Examples
795
794
///
@@ -1261,7 +1260,7 @@ impl<T> *mut [T] {
1261
1260
/// * The pointer must be [valid] for reads for `ptr.len() * mem::size_of::<T>()` many bytes,
1262
1261
/// and it must be properly aligned. This means in particular:
1263
1262
///
1264
- /// * The entire memory range of this slice must be contained within a single allocated object!
1263
+ /// * The entire memory range of this slice must be contained within a single [ allocated object] !
1265
1264
/// Slices can never span across multiple allocated objects.
1266
1265
///
1267
1266
/// * The pointer must be aligned even for zero-length slices. One
@@ -1283,6 +1282,7 @@ impl<T> *mut [T] {
1283
1282
/// See also [`slice::from_raw_parts`][].
1284
1283
///
1285
1284
/// [valid]: crate::ptr#safety
1285
+ /// [allocated object]: crate::ptr#allocated-object
1286
1286
#[ inline]
1287
1287
#[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
1288
1288
pub unsafe fn as_uninit_slice < ' a > ( self ) -> Option < & ' a [ MaybeUninit < T > ] > {
@@ -1311,7 +1311,7 @@ impl<T> *mut [T] {
1311
1311
/// * The pointer must be [valid] for reads and writes for `ptr.len() * mem::size_of::<T>()`
1312
1312
/// many bytes, and it must be properly aligned. This means in particular:
1313
1313
///
1314
- /// * The entire memory range of this slice must be contained within a single allocated object!
1314
+ /// * The entire memory range of this slice must be contained within a single [ allocated object] !
1315
1315
/// Slices can never span across multiple allocated objects.
1316
1316
///
1317
1317
/// * The pointer must be aligned even for zero-length slices. One
@@ -1333,6 +1333,7 @@ impl<T> *mut [T] {
1333
1333
/// See also [`slice::from_raw_parts_mut`][].
1334
1334
///
1335
1335
/// [valid]: crate::ptr#safety
1336
+ /// [allocated object]: crate::ptr#allocated-object
1336
1337
#[ inline]
1337
1338
#[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
1338
1339
pub unsafe fn as_uninit_slice_mut < ' a > ( self ) -> Option < & ' a mut [ MaybeUninit < T > ] > {
0 commit comments