Hasty Briefsbeta

Bilingual

The State of Allocators in 2026 – 6 Months Later

21 days ago
  • Custom allocators in Rust are close to stabilization, with a resurgence of activity and Nia leading the effort.
  • The initial API is minimal, focusing on the Allocator trait with allocate and deallocate methods, plus support for Vec and Box.
  • The Allocator trait will be dyn-compatible, enabling dynamic dispatch for flexibility similar to Zig.
  • Unwinding from allocators is prohibited to prevent unsoundness in operations like Vec growth.
  • The Clone trait for allocators is problematic due to potential double-free issues; a new unsafe marker trait AllocatorClone is proposed.
  • Pin and memory covariance issues show that the 'static bound alone is insufficient; a StaticAllocator marker trait is under consideration.
  • The first stabilization is an MVP, excluding Pin::new_in and other container methods while unsoundness issues are resolved.
  • Past precedents like Error::type_id and std::env::set_var show unsoundness can lead to reverts or making functions unsafe.
  • The stabilization process includes a final comment period and will take months to reach stable release.