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 4 commits into
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Does this have user-visible behavior changes? e.g., see #156713 |
|
Yes. With this change, both cases in #156713 pass. We also have a few user-visible consequences with the drop order lint. |
|
@rustbot reroll |
51861b3 to
d128dba
Compare
|
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. |
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.
a5dd21c to
4ff8c26
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
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