Rust Stabilizes Core Allocator API for Box and Vec
Rust stabilizes the Allocator trait and custom-allocator support for Box and Vec, tightening safety rules and fixing key soundness bugs.
Rust's allocator_api feature has cleared stabilization for a core MVP subset covering the Allocator trait and custom-allocator support in Box and Vec. Driven by wg-allocators and RFC 1398, the work has been split: the stabilized surface ships now, while remaining functionality moves to a new allocator_ext feature.
The stabilized trait substantially tightens safety requirements. Implementors must not invalidate allocated memory on drop or mutable access, and must never unwind from any Allocator method or destructor. A previously assumed but improperly documented Clone-related invariant was dropped as unenforceable and deferred to a future unstable marker trait. Allocator is now dyn-compatible, and Box/Vec gain new constructors and accessors for custom allocators, plus blanket implementations for references, Box, Rc, and Arc.
The stabilization effort also surfaced real soundness bugs, particularly around Box's covariance over its allocator interacting with Clone and Pin. As a result, Box::into_pin with custom allocators is deferred, and a new unstable StaticAllocator marker trait, implemented for Global and System, will gate pin-safety guarantees, with the existing noalias hack moved into an unstable NativeAllocator wrapper aligned with upcoming LLVM allocator intrinsics.
This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work