@@ -184,6 +184,11 @@ pub const unsafe trait Allocator {
184184 /// * `ptr` must denote a block of memory [*currently allocated*] via this allocator, and
185185 /// * `layout` must [*fit*] that block of memory.
186186 ///
187+ /// Note that it is UB for a deallocation or reallocation to invalidate any
188+ /// outstanding references, `Rc<_>`s, etc.; thus, notably, an allocator that has
189+ /// been moved into its own [*currently allocated*] memory must not be invalidated
190+ /// by a call to this method, as it would invalidate the `&self` reference used.
191+ ///
187192 /// [*currently allocated*]: #currently-allocated-memory
188193 /// [*fit*]: #memory-fitting
189194 #[ stable( feature = "allocator_api" , since = "CURRENT_RUSTC_VERSION" ) ]
@@ -387,8 +392,8 @@ pub const unsafe trait Allocator {
387392/// Marks a type's [`Clone`] implementation as sound with regard to [`Allocator`].
388393/// Implementors must ensure that, upon cloning, the two allocators are interchangeable
389394/// (i.e. is is possible to free memory with one that was allocated with the other).
390- /// Further, accesses such as moving or dropping the allocator must not invalidate
391- /// its pointed-to memory at least so long as clones exist.
395+ /// Further, mutable accesses such as moving or dropping the allocator must not invalidate
396+ /// its currently allocated blocks at least so long as clones exist.
392397#[ unstable( feature = "allocator_ext" , issue = "32838" , implied_by = "allocator_api" ) ]
393398pub unsafe trait AllocatorClone : Allocator + Clone { }
394399
@@ -398,7 +403,11 @@ pub unsafe trait AllocatorClone: Allocator + Clone {}
398403/// that the two allocators behave "as if" they are clones of each other as per
399404/// [`AllocatorClone`].
400405#[ unstable( feature = "allocator_ext" , issue = "32838" , implied_by = "allocator_api" ) ]
401- pub unsafe trait AllocatorEq < T : ?Sized = Self > : Allocator + PartialEq < T > { }
406+ pub unsafe trait AllocatorEq < T = Self > : Allocator + PartialEq < T >
407+ where
408+ T : ?Sized + AllocatorEq < Self > ,
409+ {
410+ }
402411
403412/// Marks that an allocator will not break [`Pin`] guarantees, even if subtyped with a
404413/// shorter lifetime. This trivially applies to allocators that always maintain
0 commit comments