Skip to content

emit StorageLive and schedule StorageDead for let-else's bindings after matching #143028

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dianne
Copy link
Contributor

@dianne dianne commented Jun 25, 2025

This PR removes special handling of let-else, so that StorageLives are emitted and StorageDeads are scheduled only after pattern-matching has succeeded. This means StorageDeads will no longer appear for all of its bindings on the else branch (because they're not live yet) and its drops&StorageDeads will happen together like they do elsewhere, rather than having all drops first, then all StorageDeads.

This fixes #142056, and is therefore a breaking change. I believe it'll need a crater run and a T-lang nomination/fcp thereafter. Specifically, this makes drop-checking slightly more restrictive for let-else to match the behavior of other variable binding forms. An alternative approach could be to change the relative order of drops and StorageDeads for other binding forms to make drop-checking more permissive, but making that consistent would be a significantly more involved change.

r? mir
cc @dingxiangfei2009

@rustbot label +T-lang +needs-crater

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 25, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 25, 2025

Some changes occurred in match lowering

cc @Nadrieril

@rustbot
Copy link
Collaborator

rustbot commented Jun 25, 2025

Error: Label needs-crater can only be set by Rust team members

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

@workingjubilee workingjubilee added the needs-crater This change needs a crater run to check for possible breakage in the ecosystem. label Jun 25, 2025
@workingjubilee
Copy link
Member

Building for crater:
@bors2 try

@rust-bors
Copy link

rust-bors bot commented Jun 25, 2025

⌛ Trying commit c6a97d3 with merge 8a03786

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 25, 2025
emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching

This PR removes special handling of `let`-`else`, so that `StorageLive`s are emitted and `StorageDead`s are scheduled only after pattern-matching has succeeded. This means `StorageDead`s will no longer appear for all of its bindings on the `else` branch (because they're not live yet) and its drops&`StorageDead`s will happen together like they do elsewhere, rather than having all drops first, then all `StorageDead`s.

This fixes #142056, and is therefore a breaking change. I believe it'll need a crater run and a T-lang nomination/fcp thereafter. Specifically, this makes drop-checking slightly more restrictive for `let`-`else` to match the behavior of other variable binding forms. An alternative approach could be to change the relative order of drops and `StorageDead`s for other binding forms to make drop-checking more permissive, but making that consistent would be a significantly more involved change.

r? mir
cc `@dingxiangfei2009`

`@rustbot` label +T-lang +needs-crater
@rust-bors
Copy link

rust-bors bot commented Jun 26, 2025

☀️ Try build successful (CI)
Build commit: 8a03786 (8a0378607d6b34c242e3bfa75554871be641864b, parent: d14d202262d13df896b0c624b0cec6e4bfde631a)

@workingjubilee
Copy link
Member

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-143028 created and queued.
🤖 Automatically detected try build 8a03786
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 26, 2025
@craterbot
Copy link
Collaborator

🚧 Experiment pr-143028 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-crater This change needs a crater run to check for possible breakage in the ecosystem. S-waiting-on-crater Status: Waiting on a crater run to be completed. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

drop-checking is more permissive when let statements have an else block
5 participants