Skip to content

Commit 79fe1d5

Browse files
committed
stricter reqs for staticallocator
1 parent c7eb1a4 commit 79fe1d5

3 files changed

Lines changed: 6 additions & 45 deletions

File tree

library/core/src/alloc/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,11 @@ where
473473
{
474474
}
475475

476-
/// Marks that an allocator will behave as if it were `'static`, even if subtyped
477-
/// with a shorter lifetime. This trivially applies to allocators that always maintain
478-
/// global state, e.g. `System` or `Global`. Notably, the requirement means that
479-
/// downstream consumers may rely on this allocator not invalidating its currently
480-
/// allocated memory even if its lifetime has expired.
476+
/// Marks that an allocator will never invalidate currently allocated memory, even
477+
/// if its lifetime expires or a mutable reference to it is acquired. This trivially
478+
/// applies to allocators that always maintain global state, e.g. `System` or `Global`.
479+
/// Notably, this means that the only way for memory obtained from such an allocator
480+
/// to be invalidated is an explicit call to a de/reallocating method.
481481
///
482482
/// This is a necessity in conjunction with [`Pin`], as only `'static` allocators may
483483
/// be used to back a pinned pointer.
@@ -641,6 +641,7 @@ unsafe impl<A: Allocator + ?Sized> DynAllocator for A {
641641
// FIXME(nia-e): See if it's possible to make this built-in to the typesystem,
642642
// e.g. by making the impl work on arbitrary `dyn DynAlloc + Foo + Bar`. Otherwise,
643643
// just expand this macro with other trait combinations for now.
644+
// https://rust.tf/157506
644645

645646
macro_rules! impl_dyn_allocator {
646647
($t:ty, $($n:ty),+) => {

tests/ui/allocator/dyn-incompatible.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ui/allocator/dyn-incompatible.stderr

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)