RC RANDOM CHAOS

Rust may add Move and Forget traits to replace Pin and guarantee destructors

· via Hacker News

Original source

Rust project goals: Immobile types and guaranteed destructors

Hacker News →

Rust’s type system has always assumed two things about every value: it can be relocated in memory, and it can be discarded via mem::forget without running its destructor. A proposed 2026 project goal challenges both assumptions by adding new auto-traits — Move, Destruct, and Forget — that let a type opt out of these capabilities. The design mirrors the ongoing Sized hierarchy work, which similarly relaxed the once-universal rule that every type has a compile-time-known size.

The immediate payoff is two long-standing pain points. Types marked !Move stay at a stable address for their entire life, giving self-referential types (notably async futures) a cleaner foundation than Pin, which encodes immovability on memory locations rather than on types themselves. Types marked !Forget cannot be leaked, so their destructors are guaranteed to run — the missing ingredient for safe scoped async spawning, where a task handle must join before its borrowed scope exits. Both patterns are effectively impossible in safe Rust today.

The authors frame this explicitly as an alternative to continued investment in Pin ergonomics, arguing that baking pin syntax into the language would be a permanent maintenance burden for a mechanism they ultimately want to deprecate. The plan is deliberately scoped: build compiler MVPs, write RFCs, and validate against real Linux kernel code, while leaving the Pin-dependent Future trait untouched this cycle since migrating it is a separate, harder problem.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.