-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Change destructuring assignment lowering to use match
.
#96588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change destructuring assignment lowering to use match
.
#96588
Conversation
Previously, `(a, b) = t` produced code like `{ let (lhs1, lhs2) = t; a = lhs1; b = lhs2; }`, with this commit instead we produce `match t { (lhs1, lhs2) => { a = lhs1; b = lhs2; } }`. The desired effect is to make sure that temporaries in the expression `t` aren't dropped too early, in order to get better consistency between the behavior of e.g. `x = t` vs. `[x] = [t]` or `(x,) = (t,)` (where `t` is an arbitrary expression).
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
The job Click to see the possible cause of the failure (guessed by this bot)
|
@bors try |
⌛ Trying commit 33eac80 with merge 37c8ca9437b76fdac722d51b7bfac3893dc01c1c... |
☀️ Try build successful - checks-actions |
@craterbot test |
🚨 Error: failed to parse the command 🆘 If you have any trouble with Crater please ping |
Trying to address the diagnostics change that causes CI failure, I found that the current logic is flawed leading to code like this ICEing on current nightly fn main() {
let x: usize;
while (x,) = (0_usize,) {}
} I’ll come back to this (and open another issue, etc…) tomorrow. |
Ping from triage: |
Previously, lowering
(a, b) = t
produced code like{ let (lhs1, lhs2) = t; a = lhs1; b = lhs2; }
,with this PR,
match t { (lhs1, lhs2) => { a = lhs1; b = lhs2; } }
is produced instead.The desired effect is to make sure that temporaries in the expression
t
aren't dropped too early,in order to get better consistency between the behavior of e.g.
x = t
vs.[x] = [t]
or(x,) = (t,)
(where
t
is an arbitrary expression).Fixes #96579
As also discussed shortly here, this is a breaking change (most commonly affecting drop order of temporaries of the RHS vs. old values in the places that are being assigned) and thus this will need a crater run, and probably approval from T-lang.
The PR is still missing tests at this point. And there's a
FIXME
to be addressed/discussed (though theFIXME
is no blocker for a crater run, as AFAICT – in anything – it could only affect diagnostics).