The Rust project is proposing to introduce new traits that explicitly describe operations possible on a type. Currently, Rust assumes all types can be moved (relocated in memory) and forgotten (via `mem::forget` without running destructors). The new traits, `Move`, `Destruct`, and `Forget`, will allow types to opt out of these default capabilities.
Many asynchronous futures require self-referential structures, but these types cannot be safely moved. The existing `Pin` mechanism encodes immovability as a property of memory locations rather than types, leading to complexity. The proposed `Move` trait will encode movability as a type property, simplifying the handling of self-referential types, particularly in systems like the Linux kernel.
Some types, such as `Transaction` or scoped task handles, require their destructors to execute to perform necessary cleanup or finalization. Rust's `mem::forget` function, which prevents destructors from running, is currently safe. This prevents guarantees for destructor execution. The new `Destruct` and `Forget` traits will enable types to ensure their destructors always run, supporting patterns like safe scoped spawns for asynchronous operations.
This proposal follows the precedent set by the `Sized` hierarchy work, which relaxed the assumption that all types have a compile-time-known size. The project plans to implement Minimum Viable Products (MVPs) in the compiler, write RFCs, and validate the viability through real-world testing, including integration with the Linux Kernel.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
The Rust project proposes introducing new `Move`, `Destruct`, and `Forget` traits to explicitly define type capabilities, allowing types to opt out of default assumptions about movability and destructor execution. This change addresses complexities with self-referential types and ensures critical cleanup operations, impacting how certain advanced programming patterns are handled in Rust.