Uh oh!
There was an error while loading. Please reload this page.
Mark more locals as moved to avoid building drops for them. - #158281
Mark more locals as moved to avoid building drops for them.#158281cjgillot wants to merge 5 commits into
Conversation
rustbot
commented
Jun 23, 2026
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
rustbot
commented
Jun 23, 2026
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
theemathas
commented
Jun 23, 2026
Does this have user-visible behavior changes? e.g., see #156713 |
cjgillot
commented
Jun 23, 2026
Yes. With this change, both cases in #156713 pass. We also have a few user-visible consequences with the drop order lint. |
JohnTitor
commented
Jun 27, 2026
@rustbot reroll |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjgillot
commented
Jul 9, 2026
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
734e208 to
4ad2c3fCompare
This comment has been minimized.
This comment has been minimized.
jackh726
commented
Aug 7, 2026
I'm not personally very familiar with when we are allowed to avoid building drops (specifically, which are these truly count as moves from an opsem perspective). cc both @rust-lang/opsem and @rust-lang/types I would be far more comfortable if there was a small and specific test demonstrating the difference from marking each individual site that we record as moved. |
I'm afraid MIR building is mostly outside my wheelhouse. |
RalfJung
commented
Aug 8, 2026
Is there somewhere a high-level description of the algorithm implemented here and how it defines "move"? |
cjgillot
commented
Aug 8, 2026
At high level, the doc-comment on
This is on the "built" MIR phase. In short, a "move" is an occurrence of |
4ad2c3f to
c18975aCompare
This comment has been minimized.
This comment has been minimized.
cjgillot
commented
Aug 8, 2026
Latest push adds a |
RalfJung
commented
Aug 8, 2026
"de-initialize" here refers to the initialization state tracked for drop flags, right? |
This comment has been minimized.
This comment has been minimized.
cjgillot
commented
Aug 8, 2026
Yes |
c18975a to
1811466Compare
This comment has been minimized.
This comment has been minimized.
RalfJung
commented
Aug 8, 2026
This should probably be mentioned in the |
1811466 to
6e4bdc1Comparerustbot
commented
Aug 8, 2026
This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @vakaras |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
And some more cases along the way. We have a specific optimization to avoid generating useless drops, use it. In particular, aggregate construction are very similar to function calls for which this is designed.
6e4bdc1 to
a9aef0fComparerustbot
commented
Aug 15, 2026
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
☔ The latest upstream changes made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
View all comments
MIR building skips generating drops for moved-from locals in the topmost scope. This was only used for call terminators, but can be generalized to many other moves. This PR generalizes this to aggregate construction and many other assignments.
This avoids generating drops that would then be removed by drop elaboration.
This PR changes borrowck behaviour: some programs that were rejected are now accepted, see the last commit. That particular case was wrongly rejected.
Fixes#156713
Based on #158279 to remove a lint false-positive