← All stories
● Covered by 1 source · 1 reportMedium impact1 neutral

Rust proposes new traits for immobile types and guaranteed destructors

🔄 Updated 1d ago
New to BrevFeed? We gather this story from every outlet covering it into one summary — ranked by real-world impact, not just the latest headline — so you never miss what matters. What is BrevFeed? →

Key points

  • New `Move`, `Destruct`, and `Forget` traits are proposed for Rust.
  • These traits define if a type can be relocated, implicitly dropped, or forgotten.
  • The change addresses issues with self-referential types and guaranteed destructor execution.
  • It follows the precedent of the `Sized` hierarchy work.

Addressing Core Type Assumptions

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.

Solving Immobile Types and Self-Referential Data

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.

Ensuring Guaranteed Destructors

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.

Precedent and Implementation

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 →

The daily brief

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.

Today's brief

Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.

~7 min · 6 stories · Aug 15

▶ Play today's brief Listen on Spotify

New every morning, and the back catalogue is archived by date.

Reporting from

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.