Skip to content

Commit e32c69a

Browse files
committed
terminology: allocated object → allocation
1 parent ac17c34 commit e32c69a

File tree

9 files changed

+158
-155
lines changed

9 files changed

+158
-155
lines changed

library/core/src/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl CStr {
207207
/// * `ptr` must be [valid] for reads of bytes up to and including the nul terminator.
208208
/// This means in particular:
209209
///
210-
/// * The entire memory range of this `CStr` must be contained within a single allocated object!
210+
/// * The entire memory range of this `CStr` must be contained within a single allocation!
211211
/// * `ptr` must be non-null even for a zero-length cstr.
212212
///
213213
/// * The memory referenced by the returned `CStr` must not be mutated for

library/core/src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ pub const fn needs_drop<T: ?Sized>() -> bool;
17081708
/// # Safety
17091709
///
17101710
/// If the computed offset is non-zero, then both the starting and resulting pointer must be
1711-
/// either in bounds or at the end of an allocated object. If either pointer is out
1711+
/// either in bounds or at the end of an allocation. If either pointer is out
17121712
/// of bounds or arithmetic overflow occurs then this operation is undefined behavior.
17131713
///
17141714
/// The stabilized version of this intrinsic is [`pointer::offset`].

library/core/src/primitive_docs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ mod prim_usize {}
16231623
/// * if `size_of_val(t) > 0`, then `t` is dereferenceable for `size_of_val(t)` many bytes
16241624
///
16251625
/// If `t` points at address `a`, being "dereferenceable" for N bytes means that the memory range
1626-
/// `[a, a + N)` is all contained within a single [allocated object].
1626+
/// `[a, a + N)` is all contained within a single [allocation].
16271627
///
16281628
/// For instance, this means that unsafe code in a safe function may assume these invariants are
16291629
/// ensured of arguments passed by the caller, and it may assume that these invariants are ensured
@@ -1639,7 +1639,7 @@ mod prim_usize {}
16391639
/// may be unsound or become unsound in future versions of Rust depending on how this question is
16401640
/// decided.
16411641
///
1642-
/// [allocated object]: ptr#allocated-object
1642+
/// [allocation]: ptr#allocation
16431643
#[stable(feature = "rust1", since = "1.0.0")]
16441644
mod prim_ref {}
16451645

library/core/src/ptr/const_ptr.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,13 @@ impl<T: ?Sized> *const T {
384384
/// "wrapping around"), must fit in an `isize`.
385385
///
386386
/// * If the computed offset is non-zero, then `self` must be [derived from][crate::ptr#provenance] a pointer to some
387-
/// [allocated object], and the entire memory range between `self` and the result must be in
388-
/// bounds of that allocated object. In particular, this range must not "wrap around" the edge
387+
/// [allocation], and the entire memory range between `self` and the result must be in
388+
/// bounds of that allocation. In particular, this range must not "wrap around" the edge
389389
/// of the address space. Note that "range" here refers to a half-open range as usual in Rust,
390390
/// i.e., `self..result` for non-negative offsets and `result..self` for negative offsets.
391391
///
392-
/// Allocated objects can never be larger than `isize::MAX` bytes, so if the computed offset
393-
/// stays in bounds of the allocated object, it is guaranteed to satisfy the first requirement.
392+
/// Allocations can never be larger than `isize::MAX` bytes, so if the computed offset
393+
/// stays in bounds of the allocation, it is guaranteed to satisfy the first requirement.
394394
/// This implies, for instance, that `vec.as_ptr().add(vec.len())` (for `vec: Vec<T>`) is always
395395
/// safe.
396396
///
@@ -399,7 +399,7 @@ impl<T: ?Sized> *const T {
399399
/// enables more aggressive compiler optimizations.
400400
///
401401
/// [`wrapping_offset`]: #method.wrapping_offset
402-
/// [allocated object]: crate::ptr#allocated-object
402+
/// [allocation]: crate::ptr#allocation
403403
///
404404
/// # Examples
405405
///
@@ -484,28 +484,28 @@ impl<T: ?Sized> *const T {
484484
///
485485
/// This operation itself is always safe, but using the resulting pointer is not.
486486
///
487-
/// The resulting pointer "remembers" the [allocated object] that `self` points to
487+
/// The resulting pointer "remembers" the [allocation] that `self` points to
488488
/// (this is called "[Provenance](ptr/index.html#provenance)").
489-
/// The pointer must not be used to read or write other allocated objects.
489+
/// The pointer must not be used to read or write other allocations.
490490
///
491491
/// In other words, `let z = x.wrapping_offset((y as isize) - (x as isize))` does *not* make `z`
492492
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
493493
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
494-
/// `x` and `y` point into the same allocated object.
494+
/// `x` and `y` point into the same allocation.
495495
///
496496
/// Compared to [`offset`], this method basically delays the requirement of staying within the
497-
/// same allocated object: [`offset`] is immediate Undefined Behavior when crossing object
497+
/// same allocation: [`offset`] is immediate Undefined Behavior when crossing object
498498
/// boundaries; `wrapping_offset` produces a pointer but still leads to Undefined Behavior if a
499499
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`offset`]
500500
/// can be optimized better and is thus preferable in performance-sensitive code.
501501
///
502502
/// The delayed check only considers the value of the pointer that was dereferenced, not the
503503
/// intermediate values used during the computation of the final result. For example,
504504
/// `x.wrapping_offset(o).wrapping_offset(o.wrapping_neg())` is always the same as `x`. In other
505-
/// words, leaving the allocated object and then re-entering it later is permitted.
505+
/// words, leaving the allocation and then re-entering it later is permitted.
506506
///
507507
/// [`offset`]: #method.offset
508-
/// [allocated object]: crate::ptr#allocated-object
508+
/// [allocation]: crate::ptr#allocation
509509
///
510510
/// # Examples
511511
///
@@ -618,18 +618,18 @@ impl<T: ?Sized> *const T {
618618
/// * `self` and `origin` must either
619619
///
620620
/// * point to the same address, or
621-
/// * both be [derived from][crate::ptr#provenance] a pointer to the same [allocated object], and the memory range between
621+
/// * both be [derived from][crate::ptr#provenance] a pointer to the same [allocation], and the memory range between
622622
/// the two pointers must be in bounds of that object. (See below for an example.)
623623
///
624624
/// * The distance between the pointers, in bytes, must be an exact multiple
625625
/// of the size of `T`.
626626
///
627627
/// As a consequence, the absolute distance between the pointers, in bytes, computed on
628628
/// mathematical integers (without "wrapping around"), cannot overflow an `isize`. This is
629-
/// implied by the in-bounds requirement, and the fact that no allocated object can be larger
629+
/// implied by the in-bounds requirement, and the fact that no allocation can be larger
630630
/// than `isize::MAX` bytes.
631631
///
632-
/// The requirement for pointers to be derived from the same allocated object is primarily
632+
/// The requirement for pointers to be derived from the same allocation is primarily
633633
/// needed for `const`-compatibility: the distance between pointers into *different* allocated
634634
/// objects is not known at compile-time. However, the requirement also exists at
635635
/// runtime and may be exploited by optimizations. If you wish to compute the difference between
@@ -638,7 +638,7 @@ impl<T: ?Sized> *const T {
638638
// FIXME: recommend `addr()` instead of `as usize` once that is stable.
639639
///
640640
/// [`add`]: #method.add
641-
/// [allocated object]: crate::ptr#allocated-object
641+
/// [allocation]: crate::ptr#allocation
642642
///
643643
/// # Panics
644644
///
@@ -896,12 +896,12 @@ impl<T: ?Sized> *const T {
896896
/// "wrapping around"), must fit in an `isize`.
897897
///
898898
/// * If the computed offset is non-zero, then `self` must be [derived from][crate::ptr#provenance] a pointer to some
899-
/// [allocated object], and the entire memory range between `self` and the result must be in
900-
/// bounds of that allocated object. In particular, this range must not "wrap around" the edge
899+
/// [allocation], and the entire memory range between `self` and the result must be in
900+
/// bounds of that allocation. In particular, this range must not "wrap around" the edge
901901
/// of the address space.
902902
///
903-
/// Allocated objects can never be larger than `isize::MAX` bytes, so if the computed offset
904-
/// stays in bounds of the allocated object, it is guaranteed to satisfy the first requirement.
903+
/// Allocations can never be larger than `isize::MAX` bytes, so if the computed offset
904+
/// stays in bounds of the allocation, it is guaranteed to satisfy the first requirement.
905905
/// This implies, for instance, that `vec.as_ptr().add(vec.len())` (for `vec: Vec<T>`) is always
906906
/// safe.
907907
///
@@ -910,7 +910,7 @@ impl<T: ?Sized> *const T {
910910
/// enables more aggressive compiler optimizations.
911911
///
912912
/// [`wrapping_add`]: #method.wrapping_add
913-
/// [allocated object]: crate::ptr#allocated-object
913+
/// [allocation]: crate::ptr#allocation
914914
///
915915
/// # Examples
916916
///
@@ -1002,12 +1002,12 @@ impl<T: ?Sized> *const T {
10021002
/// "wrapping around"), must fit in an `isize`.
10031003
///
10041004
/// * If the computed offset is non-zero, then `self` must be [derived from][crate::ptr#provenance] a pointer to some
1005-
/// [allocated object], and the entire memory range between `self` and the result must be in
1006-
/// bounds of that allocated object. In particular, this range must not "wrap around" the edge
1005+
/// [allocation], and the entire memory range between `self` and the result must be in
1006+
/// bounds of that allocation. In particular, this range must not "wrap around" the edge
10071007
/// of the address space.
10081008
///
1009-
/// Allocated objects can never be larger than `isize::MAX` bytes, so if the computed offset
1010-
/// stays in bounds of the allocated object, it is guaranteed to satisfy the first requirement.
1009+
/// Allocations can never be larger than `isize::MAX` bytes, so if the computed offset
1010+
/// stays in bounds of the allocation, it is guaranteed to satisfy the first requirement.
10111011
/// This implies, for instance, that `vec.as_ptr().add(vec.len())` (for `vec: Vec<T>`) is always
10121012
/// safe.
10131013
///
@@ -1016,7 +1016,7 @@ impl<T: ?Sized> *const T {
10161016
/// enables more aggressive compiler optimizations.
10171017
///
10181018
/// [`wrapping_sub`]: #method.wrapping_sub
1019-
/// [allocated object]: crate::ptr#allocated-object
1019+
/// [allocation]: crate::ptr#allocation
10201020
///
10211021
/// # Examples
10221022
///
@@ -1106,27 +1106,27 @@ impl<T: ?Sized> *const T {
11061106
///
11071107
/// This operation itself is always safe, but using the resulting pointer is not.
11081108
///
1109-
/// The resulting pointer "remembers" the [allocated object] that `self` points to; it must not
1110-
/// be used to read or write other allocated objects.
1109+
/// The resulting pointer "remembers" the [allocation] that `self` points to; it must not
1110+
/// be used to read or write other allocations.
11111111
///
11121112
/// In other words, `let z = x.wrapping_add((y as usize) - (x as usize))` does *not* make `z`
11131113
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
11141114
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
1115-
/// `x` and `y` point into the same allocated object.
1115+
/// `x` and `y` point into the same allocation.
11161116
///
11171117
/// Compared to [`add`], this method basically delays the requirement of staying within the
1118-
/// same allocated object: [`add`] is immediate Undefined Behavior when crossing object
1118+
/// same allocation: [`add`] is immediate Undefined Behavior when crossing object
11191119
/// boundaries; `wrapping_add` produces a pointer but still leads to Undefined Behavior if a
11201120
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`add`]
11211121
/// can be optimized better and is thus preferable in performance-sensitive code.
11221122
///
11231123
/// The delayed check only considers the value of the pointer that was dereferenced, not the
11241124
/// intermediate values used during the computation of the final result. For example,
11251125
/// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
1126-
/// allocated object and then re-entering it later is permitted.
1126+
/// allocation and then re-entering it later is permitted.
11271127
///
11281128
/// [`add`]: #method.add
1129-
/// [allocated object]: crate::ptr#allocated-object
1129+
/// [allocation]: crate::ptr#allocation
11301130
///
11311131
/// # Examples
11321132
///
@@ -1185,27 +1185,27 @@ impl<T: ?Sized> *const T {
11851185
///
11861186
/// This operation itself is always safe, but using the resulting pointer is not.
11871187
///
1188-
/// The resulting pointer "remembers" the [allocated object] that `self` points to; it must not
1189-
/// be used to read or write other allocated objects.
1188+
/// The resulting pointer "remembers" the [allocation] that `self` points to; it must not
1189+
/// be used to read or write other allocations.
11901190
///
11911191
/// In other words, `let z = x.wrapping_sub((x as usize) - (y as usize))` does *not* make `z`
11921192
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
11931193
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
1194-
/// `x` and `y` point into the same allocated object.
1194+
/// `x` and `y` point into the same allocation.
11951195
///
11961196
/// Compared to [`sub`], this method basically delays the requirement of staying within the
1197-
/// same allocated object: [`sub`] is immediate Undefined Behavior when crossing object
1197+
/// same allocation: [`sub`] is immediate Undefined Behavior when crossing object
11981198
/// boundaries; `wrapping_sub` produces a pointer but still leads to Undefined Behavior if a
11991199
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`sub`]
12001200
/// can be optimized better and is thus preferable in performance-sensitive code.
12011201
///
12021202
/// The delayed check only considers the value of the pointer that was dereferenced, not the
12031203
/// intermediate values used during the computation of the final result. For example,
12041204
/// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
1205-
/// allocated object and then re-entering it later is permitted.
1205+
/// allocation and then re-entering it later is permitted.
12061206
///
12071207
/// [`sub`]: #method.sub
1208-
/// [allocated object]: crate::ptr#allocated-object
1208+
/// [allocation]: crate::ptr#allocation
12091209
///
12101210
/// # Examples
12111211
///
@@ -1597,8 +1597,8 @@ impl<T> *const [T] {
15971597
/// * The pointer must be [valid] for reads for `ptr.len() * size_of::<T>()` many bytes,
15981598
/// and it must be properly aligned. This means in particular:
15991599
///
1600-
/// * The entire memory range of this slice must be contained within a single [allocated object]!
1601-
/// Slices can never span across multiple allocated objects.
1600+
/// * The entire memory range of this slice must be contained within a single [allocation]!
1601+
/// Slices can never span across multiple allocations.
16021602
///
16031603
/// * The pointer must be aligned even for zero-length slices. One
16041604
/// reason for this is that enum layout optimizations may rely on references
@@ -1619,7 +1619,7 @@ impl<T> *const [T] {
16191619
/// See also [`slice::from_raw_parts`][].
16201620
///
16211621
/// [valid]: crate::ptr#safety
1622-
/// [allocated object]: crate::ptr#allocated-object
1622+
/// [allocation]: crate::ptr#allocation
16231623
///
16241624
/// # Panics during const evaluation
16251625
///

0 commit comments

Comments
 (0)