Skip to content

MIR move elimination#3943

Open
Amanieu wants to merge 1 commit intorust-lang:masterfrom
Amanieu:mir-move-elimination
Open

MIR move elimination#3943
Amanieu wants to merge 1 commit intorust-lang:masterfrom
Amanieu:mir-move-elimination

Conversation

@Amanieu
Copy link
Copy Markdown
Member

@Amanieu Amanieu commented Apr 3, 2026

This RFC proposes changes to Rust's operational semantics and MIR representation to enable elimination of unnecessary copies of local variables. Specifically, it makes accessing memory after a move undefined behavior, and redefines the allocation lifetime of local variables to be tied to their initialized state rather than their lexical scope. Finally, it introduces a new MIR optimization pass which exploits these guarantees to eliminate copies between locals when it is safe to do so.

Important

Since RFCs involve many conversations at once that can be difficult to follow, please use review comment threads on the text changes instead of direct comments on the RFC.

If you don't have a particular section of the RFC to comment on, you can click on the "Comment on this file" button on the top-right corner of the diff, to the right of the "Viewed" checkbox. This will create a separate thread even if others have commented on the file too.

Rendered

@NobodyXu
Copy link
Copy Markdown

NobodyXu commented Apr 3, 2026

For Copy-iable types, can rust mir just drop them after the last usage, given that it cannot have a Drop implementation?

It seems to be extremely strange to say I need a move keyword on a Copy-iable type just so the compiler can optimize it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants