-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 scope of temporaries in match guards #88678
Conversation
Each pattern in a match arm has its own copy of the match guard in MIR, with its own temporary, so it has to be dropped before the the guards are joined to the single copy of the arm.
@bors r+ rollup=never p=1 need to get it in before beta cutoff |
📌 Commit ad7f109 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (1c858ba): comparison url. Summary: This change led to very small relevant improvements 🎉 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression |
The waiting on review label was added accidentally, since we're now posting perf results after merges happen. I'll remove the label. @rustbot label: -S-waiting-on-review Also, this change is very small and is not considered "definitely relevant". In the future, such a change would be registered as "not a significant performance impact". |
Beta-nominating for backport to 1.56 because it seems that #88572 landed in 1.56, which is now beta, but this fix landed in 1.57. See also the discussion on Zulip. |
Add a regression test for rust-lang#88649 I noticed that rust-lang#88649 does not have a regression test, so I add one in this PR. The test fails with this without rust-lang#88678: ``` error[E0080]: evaluation of constant value failed --> /checkout/src/test/ui/consts/issue-88649.rs:13:52 | LL | Foo::Variant1(x) | Foo::Variant2(x) if x => {} | ^ StorageLive on a local that was already live error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. ```
Discussion on the compiler team meeting led to some questions: Is the scope of #88649 restricted to just |
beta backport approved. See also PR #88691 |
(Don't forget the label -- I only noticed this because of the comment on the other PR) |
The original bug only affects match guards. The comment in the PR refers to making a similar change for |
[beta] backports - rustdoc: Fix ICE with `doc(hidden)` on tuple variant fields rust-lang#88639 - Fix 2021 `dyn` suggestion that used code as label rust-lang#88657 - Workaround blink/chromium grid layout limitation of 1000 rows rust-lang#88776 - Change scope of temporaries in match guards rust-lang#88678 - Add a regression test for rust-lang#88649 rust-lang#88691 - Revert anon union parsing rust-lang#88775 - Disable validate_maintainers. rust-lang#88977 Also drop stage0 rustfmt, because that's only supposed to be used on master. r? `@Mark-Simulacrum`
Each pattern in a match arm has its own copy of the match guard in MIR, with its own temporary, so it has to be dropped before the the guards are joined to the single copy of the arm. This PR changes
then_else_break
to allow it to put the temporary in the innermost scope possible. This change isn't done forif
expressions because that affects a large number of mir-opt tests and could more significantly affect performance.closes #88649
r? @oli-obk