Skip to content

Commit e07f57c

Browse files
authored
Rollup merge of #70691 - TimDiekmann:allocref-docs, r=RalfJung
Improve docs in `AllocRef` r? @RalfJung
2 parents 4cba69e + 0b61239 commit e07f57c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/libcore/alloc/mod.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ impl fmt::Display for AllocErr {
3333
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
3434
#[unstable(feature = "allocator_api", issue = "32838")]
3535
pub enum AllocInit {
36-
/// The contents of the new memory are undefined.
37-
///
38-
/// Reading uninitialized memory is Undefined Behavior; it must be initialized before use.
36+
/// The contents of the new memory are uninitialized.
3937
Uninitialized,
4038
/// The new memory is guaranteed to be zeroed.
4139
Zeroed,
@@ -196,7 +194,11 @@ pub unsafe trait AllocRef {
196194
///
197195
/// # Safety
198196
///
199-
/// `memory` must be a memory block returned by this allocator.
197+
/// * `ptr` must be [*currently allocated*] via this allocator, and
198+
/// * `layout` must [*fit*] the `ptr`.
199+
///
200+
/// [*currently allocated*]: #currently-allocated-memory
201+
/// [*fit*]: #memory-fitting
200202
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout);
201203

202204
/// Attempts to extend the memory block.
@@ -237,7 +239,7 @@ pub unsafe trait AllocRef {
237239
// * `new_size must be strictly greater than `memory.size` or both are zero
238240
/// * `new_size` must be greater than or equal to `layout.size()`
239241
/// * `new_size`, when rounded up to the nearest multiple of `layout.align()`, must not overflow
240-
/// (i.e., the rounded value must be less than `usize::MAX`).
242+
/// (i.e., the rounded value must be less than or equal to `usize::MAX`).
241243
///
242244
/// [*currently allocated*]: #currently-allocated-memory
243245
/// [*fit*]: #memory-fitting

0 commit comments

Comments
 (0)