Rust 1.99 Turns `Box::leak` Into an Ownership Review Trigger
Rust 1.99 updates the `Box::leak` guidance ahead of custom allocator stabilization, warning developers against reclaiming leaked allocations through later pointer round-trips.

Rust 1.99.0, released on October 1, adds an important ownership signal without changing the language: the standard-library documentation now recommends against taking memory returned by Box::leak and later deallocating it.
Box::leak converts a Box<T> into a reference whose lifetime can be extended, making it useful for deliberately permanent data such as process-wide configuration or registries. The risk appears when a program treats that reference as a temporary escape hatch, later reconstructs ownership through a raw pointer, and attempts to free the allocation.
The Rust release team says this round-trip pattern can interact badly with current and future compiler optimizations, with the concern becoming more significant as custom allocators approach stabilization. Rust 1.99 therefore recommends Box::into_raw or the newly stabilized Box::into_non_null when the allocation must eventually be reclaimed. Those APIs preserve an explicit ownership transition instead of presenting the allocation as leaked for the lifetime of a reference.
For library authors, the practical review question is no longer simply “does this compile?” It is “is this allocation intentionally permanent?” Search unsafe code and FFI adapters for Box::leak, raw-pointer reconstruction, and manual deallocation. If reclamation is part of the design, use an ownership-preserving conversion and document the allocator and deallocation contract.
A caveat matters: Rust 1.99 changes the documentation recommendation, not the language semantics. Intentional leaks remain a valid design choice; the warning is aimed at patterns that leak first and reclaim later.
Get the wire in your inbox
Every new signal, straight from the generator. No noise, unsubscribe anytime.


