Repository navigation
Description
This is a tracking issue for experimental work related to the Move auto trait.
The feature gate for the issue is TODO.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Background
We’d like to propose an experiment for a new trait auto-trait Move that determines whether a type can be freely moved around or must keep a stable memory location. This is intended to be a safe and simple language-level alternative to the existing pinning system. At the heart of this is a new auto-trait Move with default bounds:
#[lang = "default_trait"]
unsafe auto trait Move {}By default all types implement Move which enables them to change memory locations, which is how Rust behaves today. But if a type chooses to implement !Move, the compiler will guarantee that that type will have a stable location in memory until it is has finished dropping.
This work will initially only focus on introducing the Move trait and enabling the compiler to enforce those checks. We’re intentionally not (yet) focusing on backwards-compatibility with existing traits, migrating existing uses of Pin, or more advanced features like move-constructors.
@lcnr and I recently ran an experiment for this in the compiler, proving that this work should be feasible. We were initially quite concerned with potential performance regressions, but on further investigation we determined this should be manageable.
Relationship to other experiments
In-place initialization
This work compliments Project Goal 2025H2: In-place initialization, which enables types to be constructed in a stable memory location. This makes it possible to return !Move types directly from constructors without needing to copy data, which is done by writing data to an out-pointer rather than being copied out of a function.
Pin ergonomics
This work is an alternative to Project Goal 2025H2: Continue Experimentation with Pin Ergonomics, which includes the following extensions:
- A new item kind
pinin lvalues, e.g.&pin x,&pin mut x,&pin const x. - A one-off overload of Rust’s
Droptrait, e.g.fn drop(&pin mut self). - A new item kind
pinin patterns, e.g.&pin <pat>.
We will refrain from litigating the differences between proposals here. But suffice to say: we are aware of this proposal and we believe that Move is the better direction. We’re filing for a lang experiment so we can prove this by implementing it.
Further Reading
- Ergonomic Self-Referential Types > Immovable Types Yosh Wuyts, 2024
- Adding implicit auto-trait bounds is hard lcnr, 2025
Movetrait perf test #146201 lcnr, 2025- Initial support for auto traits with default bounds #120706 Bryanskiy, 2024
- Project Goal 2025H2: In-place initialization Alice Ryhl, 2025
Contacts
Some relevant contacts:
- Design: @yoshuawuyts
- Implementation: @nia-e, @lcnr
- Compiler team liaison/reviewer: @lcnr
- Lang liaison: @jackh726
Steps
- Approve as lang experiment.
- Implement in nightly.
- Accept an RFC.
- Add documentation to the dev guide.
- See the instructions.
- Add documentation to the reference.
- See the instructions.
- Add formatting for new syntax to the style guide.
- See the nightly style procedure.
- Stabilize.
- See the instructions.
Unresolved Questions
Implementation History
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
[-]Experiment proposal: `Move` auto-trait[/-][+]Experiment proposal: `Move` trait[/+]traviscross commentedon Dec 3, 2025
We reviewed this in the lang call today for context. Thanks @yoshuawuyts for pushing forward on this experiment. @jackh726, in his role as a lang-advisor, volunteered to champion this.
scottmcm commentedon Dec 3, 2025
There's a bunch of stuff around here like how to mix opt-outs with the direction away from
?Sizedin the sized trait hierarchy, and all the previous looks at this wanted to not do that because of other complications like how to deal with them in associated types.But happy to have the experiment go ahead and see where it ends up!
[-]Experiment proposal: `Move` trait[/-][+]Tracking issue: `Move` trait[/+]jackh726 commentedon Dec 3, 2025
Updated the OP to match more the tracking issue format.
yoshuawuyts commentedon Jan 27, 2026
We've filed a 2026 project goal: rust-lang/goals#469
miss-programgamer commentedon Sep 9, 2026
If I may, would it be possible to allow for explicit implementations of the
Movetrait to provide a method (perhaps calledmove) that can be used to track the movements of a type rather than entirely forbid movement with!Move? Sometimes it's not that moving something would break things, but that we should simply update the internal state of some object with its new address prior to moving it. The main use case I have in mind is some sort of window type wrappingHWNDon Windows where the address of the wrapping type is stored in the window's userdata pointer, allowing the wrapper type to also hold its state. I don't know if allowing this would complicate move semantics enough to impact performance (both compilation speed and program speed are considerations) but if it's not too much trouble then I'd like to ask that you please consider it!bjorn3 commentedon Sep 10, 2026
At the very least that would need to be a separate trait. Unsafe code cam and does assume that movable types can be moved using memcpy. So for soundness you did have to make sure unsafe code believes such types to not be movable. Also running arbitrary code on move os almost certainly going to lead to a ton of reentrancy issues that can cause UB. Already with Drop impls we have reentrancy issues. By the way, not sure if we should have this discussion on a tracking issue.
onestacked commentedon Sep 10, 2026
I think something like
trait Relocatewith a.relocatefunction would be nice. I don't really think having an implicit (non trivial) move operation is a good choice.yoshuawuyts commentedon Sep 10, 2026
A reminder for folks in this thread that tracking issues are not intended for feature discussions. You're encouraged to either open new issues or move the discussion to Zulip. From the first comment on this issue: