Skip to content

Commit f388c98

Browse files
committed
terminology: allocated object → allocation
1 parent 852f15c commit f388c98

File tree

11 files changed

+146
-143
lines changed

11 files changed

+146
-143
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
@@ -1722,7 +1722,7 @@ pub const fn needs_drop<T: ?Sized>() -> bool;
17221722
/// # Safety
17231723
///
17241724
/// If the computed offset is non-zero, then both the starting and resulting pointer must be
1725-
/// either in bounds or at the end of an allocated object. If either pointer is out
1725+
/// either in bounds or at the end of an allocation. If either pointer is out
17261726
/// of bounds or arithmetic overflow occurs then this operation is undefined behavior.
17271727
///
17281728
/// 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: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -482,28 +482,28 @@ impl<T: ?Sized> *const T {
482482
///
483483
/// This operation itself is always safe, but using the resulting pointer is not.
484484
///
485-
/// The resulting pointer "remembers" the [allocated object] that `self` points to
485+
/// The resulting pointer "remembers" the [allocation] that `self` points to
486486
/// (this is called "[Provenance](ptr/index.html#provenance)").
487-
/// The pointer must not be used to read or write other allocated objects.
487+
/// The pointer must not be used to read or write other allocations.
488488
///
489489
/// In other words, `let z = x.wrapping_offset((y as isize) - (x as isize))` does *not* make `z`
490490
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
491491
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
492-
/// `x` and `y` point into the same allocated object.
492+
/// `x` and `y` point into the same allocation.
493493
///
494494
/// Compared to [`offset`], this method basically delays the requirement of staying within the
495-
/// same allocated object: [`offset`] is immediate Undefined Behavior when crossing object
495+
/// same allocation: [`offset`] is immediate Undefined Behavior when crossing object
496496
/// boundaries; `wrapping_offset` produces a pointer but still leads to Undefined Behavior if a
497497
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`offset`]
498498
/// can be optimized better and is thus preferable in performance-sensitive code.
499499
///
500500
/// The delayed check only considers the value of the pointer that was dereferenced, not the
501501
/// intermediate values used during the computation of the final result. For example,
502502
/// `x.wrapping_offset(o).wrapping_offset(o.wrapping_neg())` is always the same as `x`. In other
503-
/// words, leaving the allocated object and then re-entering it later is permitted.
503+
/// words, leaving the allocation and then re-entering it later is permitted.
504504
///
505505
/// [`offset`]: #method.offset
506-
/// [allocated object]: crate::ptr#allocated-object
506+
/// [allocation]: crate::ptr#allocation
507507
///
508508
/// # Examples
509509
///
@@ -616,18 +616,18 @@ impl<T: ?Sized> *const T {
616616
/// * `self` and `origin` must either
617617
///
618618
/// * point to the same address, or
619-
/// * both be [derived from][crate::ptr#provenance] a pointer to the same [allocated object], and the memory range between
619+
/// * both be [derived from][crate::ptr#provenance] a pointer to the same [allocation], and the memory range between
620620
/// the two pointers must be in bounds of that object. (See below for an example.)
621621
///
622622
/// * The distance between the pointers, in bytes, must be an exact multiple
623623
/// of the size of `T`.
624624
///
625625
/// As a consequence, the absolute distance between the pointers, in bytes, computed on
626626
/// mathematical integers (without "wrapping around"), cannot overflow an `isize`. This is
627-
/// implied by the in-bounds requirement, and the fact that no allocated object can be larger
627+
/// implied by the in-bounds requirement, and the fact that no allocation can be larger
628628
/// than `isize::MAX` bytes.
629629
///
630-
/// The requirement for pointers to be derived from the same allocated object is primarily
630+
/// The requirement for pointers to be derived from the same allocation is primarily
631631
/// needed for `const`-compatibility: the distance between pointers into *different* allocated
632632
/// objects is not known at compile-time. However, the requirement also exists at
633633
/// runtime and may be exploited by optimizations. If you wish to compute the difference between
@@ -636,7 +636,7 @@ impl<T: ?Sized> *const T {
636636
// FIXME: recommend `addr()` instead of `as usize` once that is stable.
637637
///
638638
/// [`add`]: #method.add
639-
/// [allocated object]: crate::ptr#allocated-object
639+
/// [allocation]: crate::ptr#allocation
640640
///
641641
/// # Panics
642642
///
@@ -969,12 +969,12 @@ impl<T: ?Sized> *const T {
969969
/// "wrapping around"), must fit in an `isize`.
970970
///
971971
/// * If the computed offset is non-zero, then `self` must be [derived from][crate::ptr#provenance] a pointer to some
972-
/// [allocated object], and the entire memory range between `self` and the result must be in
973-
/// bounds of that allocated object. In particular, this range must not "wrap around" the edge
972+
/// [allocation], and the entire memory range between `self` and the result must be in
973+
/// bounds of that allocation. In particular, this range must not "wrap around" the edge
974974
/// of the address space.
975975
///
976-
/// Allocated objects can never be larger than `isize::MAX` bytes, so if the computed offset
977-
/// stays in bounds of the allocated object, it is guaranteed to satisfy the first requirement.
976+
/// Allocations can never be larger than `isize::MAX` bytes, so if the computed offset
977+
/// stays in bounds of the allocation, it is guaranteed to satisfy the first requirement.
978978
/// This implies, for instance, that `vec.as_ptr().add(vec.len())` (for `vec: Vec<T>`) is always
979979
/// safe.
980980
///
@@ -983,7 +983,7 @@ impl<T: ?Sized> *const T {
983983
/// enables more aggressive compiler optimizations.
984984
///
985985
/// [`wrapping_sub`]: #method.wrapping_sub
986-
/// [allocated object]: crate::ptr#allocated-object
986+
/// [allocation]: crate::ptr#allocation
987987
///
988988
/// # Examples
989989
///
@@ -1073,27 +1073,27 @@ impl<T: ?Sized> *const T {
10731073
///
10741074
/// This operation itself is always safe, but using the resulting pointer is not.
10751075
///
1076-
/// The resulting pointer "remembers" the [allocated object] that `self` points to; it must not
1077-
/// be used to read or write other allocated objects.
1076+
/// The resulting pointer "remembers" the [allocation] that `self` points to; it must not
1077+
/// be used to read or write other allocations.
10781078
///
10791079
/// In other words, `let z = x.wrapping_add((y as usize) - (x as usize))` does *not* make `z`
10801080
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
10811081
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
1082-
/// `x` and `y` point into the same allocated object.
1082+
/// `x` and `y` point into the same allocation.
10831083
///
10841084
/// Compared to [`add`], this method basically delays the requirement of staying within the
1085-
/// same allocated object: [`add`] is immediate Undefined Behavior when crossing object
1085+
/// same allocation: [`add`] is immediate Undefined Behavior when crossing object
10861086
/// boundaries; `wrapping_add` produces a pointer but still leads to Undefined Behavior if a
10871087
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`add`]
10881088
/// can be optimized better and is thus preferable in performance-sensitive code.
10891089
///
10901090
/// The delayed check only considers the value of the pointer that was dereferenced, not the
10911091
/// intermediate values used during the computation of the final result. For example,
10921092
/// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
1093-
/// allocated object and then re-entering it later is permitted.
1093+
/// allocation and then re-entering it later is permitted.
10941094
///
10951095
/// [`add`]: #method.add
1096-
/// [allocated object]: crate::ptr#allocated-object
1096+
/// [allocation]: crate::ptr#allocation
10971097
///
10981098
/// # Examples
10991099
///
@@ -1152,27 +1152,27 @@ impl<T: ?Sized> *const T {
11521152
///
11531153
/// This operation itself is always safe, but using the resulting pointer is not.
11541154
///
1155-
/// The resulting pointer "remembers" the [allocated object] that `self` points to; it must not
1156-
/// be used to read or write other allocated objects.
1155+
/// The resulting pointer "remembers" the [allocation] that `self` points to; it must not
1156+
/// be used to read or write other allocations.
11571157
///
11581158
/// In other words, `let z = x.wrapping_sub((x as usize) - (y as usize))` does *not* make `z`
11591159
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
11601160
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
1161-
/// `x` and `y` point into the same allocated object.
1161+
/// `x` and `y` point into the same allocation.
11621162
///
11631163
/// Compared to [`sub`], this method basically delays the requirement of staying within the
1164-
/// same allocated object: [`sub`] is immediate Undefined Behavior when crossing object
1164+
/// same allocation: [`sub`] is immediate Undefined Behavior when crossing object
11651165
/// boundaries; `wrapping_sub` produces a pointer but still leads to Undefined Behavior if a
11661166
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`sub`]
11671167
/// can be optimized better and is thus preferable in performance-sensitive code.
11681168
///
11691169
/// The delayed check only considers the value of the pointer that was dereferenced, not the
11701170
/// intermediate values used during the computation of the final result. For example,
11711171
/// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
1172-
/// allocated object and then re-entering it later is permitted.
1172+
/// allocation and then re-entering it later is permitted.
11731173
///
11741174
/// [`sub`]: #method.sub
1175-
/// [allocated object]: crate::ptr#allocated-object
1175+
/// [allocation]: crate::ptr#allocation
11761176
///
11771177
/// # Examples
11781178
///
@@ -1564,8 +1564,8 @@ impl<T> *const [T] {
15641564
/// * The pointer must be [valid] for reads for `ptr.len() * size_of::<T>()` many bytes,
15651565
/// and it must be properly aligned. This means in particular:
15661566
///
1567-
/// * The entire memory range of this slice must be contained within a single [allocated object]!
1568-
/// Slices can never span across multiple allocated objects.
1567+
/// * The entire memory range of this slice must be contained within a single [allocation]!
1568+
/// Slices can never span across multiple allocations.
15691569
///
15701570
/// * The pointer must be aligned even for zero-length slices. One
15711571
/// reason for this is that enum layout optimizations may rely on references
@@ -1586,7 +1586,7 @@ impl<T> *const [T] {
15861586
/// See also [`slice::from_raw_parts`][].
15871587
///
15881588
/// [valid]: crate::ptr#safety
1589-
/// [allocated object]: crate::ptr#allocated-object
1589+
/// [allocation]: crate::ptr#allocation
15901590
///
15911591
/// # Panics during const evaluation
15921592
///

library/core/src/ptr/docs/add.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ If any of the following conditions are violated, the result is Undefined Behavio
1515
"wrapping around"), must fit in an `isize`.
1616

1717
* If the computed offset is non-zero, then `self` must be [derived from][crate::ptr#provenance] a pointer to some
18-
[allocated object], and the entire memory range between `self` and the result must be in
19-
bounds of that allocated object. In particular, this range must not "wrap around" the edge
18+
[allocation], and the entire memory range between `self` and the result must be in
19+
bounds of that allocation. In particular, this range must not "wrap around" the edge
2020
of the address space.
2121

2222
Allocated objects can never be larger than `isize::MAX` bytes, so if the computed offset
23-
stays in bounds of the allocated object, it is guaranteed to satisfy the first requirement.
23+
stays in bounds of the allocation, it is guaranteed to satisfy the first requirement.
2424
This implies, for instance, that `vec.as_ptr().add(vec.len())` (for `vec: Vec<T>`) is always
2525
safe.
2626

@@ -29,4 +29,4 @@ difficult to satisfy. The only advantage of this method is that it
2929
enables more aggressive compiler optimizations.
3030

3131
[`wrapping_add`]: #method.wrapping_add
32-
[allocated object]: crate::ptr#allocated-object
32+
[allocation]: crate::ptr#allocation

library/core/src/ptr/docs/offset.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ If any of the following conditions are violated, the result is Undefined Behavio
1111
"wrapping around"), must fit in an `isize`.
1212

1313
* If the computed offset is non-zero, then `self` must be [derived from][crate::ptr#provenance] a pointer to some
14-
[allocated object], and the entire memory range between `self` and the result must be in
15-
bounds of that allocated object. In particular, this range must not "wrap around" the edge
14+
[allocation], and the entire memory range between `self` and the result must be in
15+
bounds of that allocation. In particular, this range must not "wrap around" the edge
1616
of the address space. Note that "range" here refers to a half-open range as usual in Rust,
1717
i.e., `self..result` for non-negative offsets and `result..self` for negative offsets.
1818

1919
Allocated objects can never be larger than `isize::MAX` bytes, so if the computed offset
20-
stays in bounds of the allocated object, it is guaranteed to satisfy the first requirement.
20+
stays in bounds of the allocation, it is guaranteed to satisfy the first requirement.
2121
This implies, for instance, that `vec.as_ptr().add(vec.len())` (for `vec: Vec<T>`) is always
2222
safe.
2323

@@ -26,4 +26,4 @@ difficult to satisfy. The only advantage of this method is that it
2626
enables more aggressive compiler optimizations.
2727

2828
[`wrapping_offset`]: #method.wrapping_offset
29-
[allocated object]: crate::ptr#allocated-object
29+
[allocation]: crate::ptr#allocation

0 commit comments

Comments
 (0)