Skip to content

Commit e6f12c8

Browse files
committed
Auto merge of rust-lang#136272 - Zalathar:rollup-6s577l5, r=Zalathar
Rollup of 5 pull requests Successful merges: - rust-lang#135847 (optimize slice::ptr_rotate for small rotates) - rust-lang#136215 (btree/node.rs: remove incorrect comment from pop_internal_level docs) - rust-lang#136252 (spastorino back from vacations) - rust-lang#136254 (Rustc dev guide subtree update) - rust-lang#136259 (Cleanup docs for Allocator) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5e55679 + 4059a79 commit e6f12c8

File tree

15 files changed

+296
-227
lines changed

15 files changed

+296
-227
lines changed

library/alloc/src/collections/btree/node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,8 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
600600
/// no cleanup is done on any of the keys, values and other children.
601601
/// This decreases the height by 1 and is the opposite of `push_internal_level`.
602602
///
603-
/// Requires exclusive access to the `NodeRef` object but not to the root node;
604-
/// it will not invalidate other handles or references to the root node.
603+
/// Does not invalidate any handles or references pointing into the subtree
604+
/// rooted at the first child of `self`.
605605
///
606606
/// Panics if there is no internal level, i.e., if the root node is a leaf.
607607
pub(super) fn pop_internal_level<A: Allocator + Clone>(&mut self, alloc: A) {

library/core/src/alloc/mod.rs

+27-31
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,26 @@ impl fmt::Display for AllocError {
4949
/// An implementation of `Allocator` can allocate, grow, shrink, and deallocate arbitrary blocks of
5050
/// data described via [`Layout`][].
5151
///
52-
/// `Allocator` is designed to be implemented on ZSTs, references, or smart pointers because having
53-
/// an allocator like `MyAlloc([u8; N])` cannot be moved, without updating the pointers to the
52+
/// `Allocator` is designed to be implemented on ZSTs, references, or smart pointers.
53+
/// An allocator for `MyAlloc([u8; N])` cannot be moved, without updating the pointers to the
5454
/// allocated memory.
5555
///
56-
/// Unlike [`GlobalAlloc`][], zero-sized allocations are allowed in `Allocator`. If an underlying
57-
/// allocator does not support this (like jemalloc) or return a null pointer (such as
58-
/// `libc::malloc`), this must be caught by the implementation.
56+
/// In contrast to [`GlobalAlloc`][], `Allocator` allows zero-sized allocations. If an underlying
57+
/// allocator does not support this (like jemalloc) or responds by returning a null pointer
58+
/// (such as `libc::malloc`), this must be caught by the implementation.
5959
///
6060
/// ### Currently allocated memory
6161
///
62-
/// Some of the methods require that a memory block be *currently allocated* via an allocator. This
63-
/// means that:
62+
/// Some of the methods require that a memory block is *currently allocated* by an allocator.
63+
/// This means that:
64+
/// * the starting address for that memory block was previously
65+
/// returned by [`allocate`], [`grow`], or [`shrink`], and
66+
/// * the memory block has not subsequently been deallocated.
6467
///
65-
/// * the starting address for that memory block was previously returned by [`allocate`], [`grow`], or
66-
/// [`shrink`], and
67-
///
68-
/// * the memory block has not been subsequently deallocated, where blocks are either deallocated
69-
/// directly by being passed to [`deallocate`] or were changed by being passed to [`grow`] or
70-
/// [`shrink`] that returns `Ok`. If `grow` or `shrink` have returned `Err`, the passed pointer
71-
/// remains valid.
68+
/// A memory block is deallocated by a call to [`deallocate`],
69+
/// or by a call to [`grow`] or [`shrink`] that returns `Ok`.
70+
/// A call to `grow` or `shrink` that returns `Err`,
71+
/// does not deallocate the memory block passed to it.
7272
///
7373
/// [`allocate`]: Allocator::allocate
7474
/// [`grow`]: Allocator::grow
@@ -77,32 +77,28 @@ impl fmt::Display for AllocError {
7777
///
7878
/// ### Memory fitting
7979
///
80-
/// Some of the methods require that a layout *fit* a memory block. What it means for a layout to
81-
/// "fit" a memory block means (or equivalently, for a memory block to "fit" a layout) is that the
80+
/// Some of the methods require that a `layout` *fit* a memory block or vice versa. This means that the
8281
/// following conditions must hold:
83-
///
84-
/// * The block must be allocated with the same alignment as [`layout.align()`], and
85-
///
86-
/// * The provided [`layout.size()`] must fall in the range `min ..= max`, where:
87-
/// - `min` is the size of the layout most recently used to allocate the block, and
88-
/// - `max` is the latest actual size returned from [`allocate`], [`grow`], or [`shrink`].
82+
/// * the memory block must be *currently allocated* with alignment of [`layout.align()`], and
83+
/// * [`layout.size()`] must fall in the range `min ..= max`, where:
84+
/// - `min` is the size of the layout used to allocate the block, and
85+
/// - `max` is the actual size returned from [`allocate`], [`grow`], or [`shrink`].
8986
///
9087
/// [`layout.align()`]: Layout::align
9188
/// [`layout.size()`]: Layout::size
9289
///
9390
/// # Safety
9491
///
95-
/// * Memory blocks returned from an allocator that are [*currently allocated*] must point to
96-
/// valid memory and retain their validity while they are [*currently allocated*] and the shorter
97-
/// of:
98-
/// - the borrow-checker lifetime of the allocator type itself.
99-
/// - as long as at least one of the instance and all of its clones has not been dropped.
92+
/// Memory blocks that are [*currently allocated*] by an allocator,
93+
/// must point to valid memory, and retain their validity while until either:
94+
/// - the memory block is deallocated, or
95+
/// - the allocator is dropped.
10096
///
101-
/// * copying, cloning, or moving the allocator must not invalidate memory blocks returned from this
102-
/// allocator. A copied or cloned allocator must behave like the same allocator, and
97+
/// Copying, cloning, or moving the allocator must not invalidate memory blocks returned from it
98+
/// A copied or cloned allocator must behave like the original allocator.
10399
///
104-
/// * any pointer to a memory block which is [*currently allocated*] may be passed to any other
105-
/// method of the allocator.
100+
/// A memory block which is [*currently allocated*] may be passed to
101+
/// any method of the allocator that accepts such an argument.
106102
///
107103
/// [*currently allocated*]: #currently-allocated-memory
108104
#[unstable(feature = "allocator_api", issue = "32838")]

0 commit comments

Comments
 (0)