Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix drop scope for super let bindings within if let #145342

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

Merged
bors merged 2 commits into rust-lang:master from dianne:if-let-super-let
Sep 4, 2025

Conversation

Copy link
Contributor

@dianne dianne commented Aug 13, 2025
edited
Loading

Fixes #145328 by making non-lifetime-extended super let reuse the logic used to compute drop scopes for non-lifetime-extended temporaries.

Also fixes #145374, which regressed due to #143376 introducing if let-like scopes for match arms with guards.

Tracking issue for super let: #139076

This is a regression fix / breaking change for macros stably exposing super let, including pin! and format_args!.
Nominating to be discussed alongside #145328: @rustbot label +I-lang-nominated +I-libs-api-nominated

theemathas, Nadrieril, and teor2345 reacted with heart emoji
dianne added 2 commits August 13, 2025 01:38
They now use the enclosing temporary scope as their scope, regardless of
which `ScopeData` was used to mark it.
Copy link
Collaborator

rustbot commented Aug 13, 2025

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. I-lang-nominated Nominated for discussion during a lang team meeting. I-libs-api-nominated Nominated for discussion during a libs-api team meeting. labels Aug 13, 2025
@traviscross traviscross added P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang P-lang-drag-0 Lang team prioritization drag level 0.https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang. and removed P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Aug 13, 2025
Copy link
Member

@dianne does this need crater?

Copy link
Contributor

traviscross commented Aug 13, 2025
edited
Loading

@bors2 try

This comment was marked as resolved.

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 13, 2025
fix drop scope for `super let` bindings within `if let`
Copy link

rust-bors bot commented Aug 13, 2025

☀️ Try build successful (CI)
Build commit: a498031 (a4980311fb7bb9e7893708e6bd3fbbfb2819fd3d, parent: 350d0ef0ec0493e6d21cfb265cb8211a0e74d766)

Copy link
Member

@craterbot check

Copy link
Collaborator

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

i️ 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 Aug 13, 2025
@rustbot rustbot added the stable-nominated Nominated for backporting to the compiler in the stable channel. label Aug 14, 2025
@compiler-errors compiler-errors added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 14, 2025
Copy link
Contributor

How does #145374 relate to this? The code there doesn't use super let anywhere.

Copy link
Contributor Author

dianne commented Aug 14, 2025
edited
Loading

Format arguments, e.g. as used by write!, are also implemented in terms of super let. This is visible when printing the HIR of that test case:

f.write_fmt({
 super let args =
 (&pointee.behind_pointer(),
 &ItemIdentifier::path(&ItemIdentifier::nserror()));
 super let args =
 [format_argument::new_display(args.0),
 format_argument::new_display(args.1)];
 format_arguments::new_v1(&["", ", "], &args)
 })

The interaction between that, old editions not treating block tail expressions as temporary drop scopes, my guard scoping PR, and the existing super let scoping bug is what caused that particular regression.

theemathas reacted with thumbs up emoji

@traviscross traviscross added T-lang Relevant to the language team I-lang-radar Items that are on lang's radar and will need eventual work or consideration. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 14, 2025
Copy link
Collaborator

🎉 Experiment pr-145342-1 is completed!
📊 0 regressed and 0 fixed (178704 total)
📊 39455 spurious results on the retry-regessed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
i️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates={retry_regressed_list_url}

theemathas reacted with rocket emoji

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

r? rust-lang/compiler

@rustbot rustbot assigned fee1-dead and unassigned jackh726 Aug 28, 2025
@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Aug 29, 2025
Copy link
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

Copy link
Member

r? rust-lang/compiler

Copy link
Contributor

@bors r+

theemathas reacted with rocket emoji

Copy link
Collaborator

bors commented Sep 3, 2025

📌 Commit 8fc3938 has been approved by nnethercote

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 3, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 3, 2025
...cote
fix drop scope for `super let` bindings within `if let`
Fixes rust-lang#145328 by making non-lifetime-extended `super let` reuse the logic used to compute drop scopes for non-lifetime-extended temporaries.
Also fixes rust-lang#145374, which regressed due to rust-lang#143376 introducing `if let`-like scopes for match arms with guards.
Tracking issue for `super let`: rust-lang#139076
This is a regression fix / breaking change for macros stably exposing `super let`, including `pin!` and `format_args!`.
Nominating to be discussed alongside rust-lang#145328: `@rustbot` label +I-lang-nominated +I-libs-api-nominated
bors added a commit that referenced this pull request Sep 3, 2025
Rollup of 16 pull requests
Successful merges:
 - #143725 (core: add Peekable::next_if_map)
 - #145209 (Stabilize `path_add_extension`)
 - #145342 (fix drop scope for `super let` bindings within `if let`)
 - #145750 (raw_vec.rs: Remove superfluous fn alloc_guard)
 - #145962 (Ensure we emit an allocator shim when only some crate types need one)
 - #145963 (Add LSX accelerated implementation for source file analysis)
 - #146054 (add `#[must_use]` to `array::repeat`)
 - #146090 (Derive `PartialEq` for `InvisibleOrigin`)
 - #146120 (Correct typo in `rustc_errors` comment)
 - #146127 (Rename `ToolRustc` to `ToolRustcPrivate`)
 - #146133 (Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins`)
 - #146134 (llvm: nvptx: Layout update to match LLVM)
 - #146136 (docs(std): add missing closing code block fences in doc comments)
 - #146137 (Disallow frontmatter in `--cfg` and `--check-cfg` arguments)
 - #146140 (compiletest: cygwin follows windows in using PATH for dynamic libraries)
 - #146156 (miri subtree update)
r? `@ghost`
`@rustbot` modify labels: rollup
@traviscross traviscross added the relnotes Marks issues that should be documented in the release notes of the next release. label Sep 3, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 4, 2025
...cote
fix drop scope for `super let` bindings within `if let`
Fixes rust-lang#145328 by making non-lifetime-extended `super let` reuse the logic used to compute drop scopes for non-lifetime-extended temporaries.
Also fixes rust-lang#145374, which regressed due to rust-lang#143376 introducing `if let`-like scopes for match arms with guards.
Tracking issue for `super let`: rust-lang#139076
This is a regression fix / breaking change for macros stably exposing `super let`, including `pin!` and `format_args!`.
Nominating to be discussed alongside rust-lang#145328: ``@rustbot`` label +I-lang-nominated +I-libs-api-nominated
bors added a commit that referenced this pull request Sep 4, 2025
Rollup of 24 pull requests
Successful merges:
 - #140459 (Add `read_buf` equivalents for positioned reads)
 - #143725 (core: add Peekable::next_if_map)
 - #145209 (Stabilize `path_add_extension`)
 - #145342 (fix drop scope for `super let` bindings within `if let`)
 - #145750 (raw_vec.rs: Remove superfluous fn alloc_guard)
 - #145827 (On unused binding or binding not present in all patterns, suggest potential typo of unit struct/variant or const)
 - #145932 (Allow `inline(always)` with a target feature behind a unstable feature `target_feature_inline_always`.)
 - #145962 (Ensure we emit an allocator shim when only some crate types need one)
 - #145963 (Add LSX accelerated implementation for source file analysis)
 - #146054 (add `#[must_use]` to `array::repeat`)
 - #146090 (Derive `PartialEq` for `InvisibleOrigin`)
 - #146112 (don't uppercase error messages)
 - #146120 (Correct typo in `rustc_errors` comment)
 - #146124 (Test `rustc-dev` in `distcheck`)
 - #146127 (Rename `ToolRustc` to `ToolRustcPrivate`)
 - #146131 (rustdoc-search: add test case for indexing every item type)
 - #146134 (llvm: nvptx: Layout update to match LLVM)
 - #146136 (docs(std): add missing closing code block fences in doc comments)
 - #146137 (Disallow frontmatter in `--cfg` and `--check-cfg` arguments)
 - #146140 (compiletest: cygwin follows windows in using PATH for dynamic libraries)
 - #146150 (fix(rustdoc): match rustc `--emit` precedence )
 - #146155 (Make bootstrap self test parallel)
 - #146161 ([rustdoc] Uncomment code to add scraped rustdoc examples in loaded paths)
 - #146172 (triagebot: configure some pings when certain attributes are used)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cd59ee7 into rust-lang:master Sep 4, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Sep 4, 2025
rust-timer added a commit that referenced this pull request Sep 4, 2025
Rollup merge of #145342 - dianne:if-let-super-let, r=nnethercote
fix drop scope for `super let` bindings within `if let`
Fixes #145328 by making non-lifetime-extended `super let` reuse the logic used to compute drop scopes for non-lifetime-extended temporaries.
Also fixes #145374, which regressed due to #143376 introducing `if let`-like scopes for match arms with guards.
Tracking issue for `super let`: #139076
This is a regression fix / breaking change for macros stably exposing `super let`, including `pin!` and `format_args!`.
Nominating to be discussed alongside #145328: ```@rustbot``` label +I-lang-nominated +I-libs-api-nominated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Labels
beta-nominated Nominated for backporting to the compiler in the beta channel. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team to-announce Announce this issue on triage meeting
Projects
None yet
Milestone
1.91.0
Development

Successfully merging this pull request may close these issues.

Regression when dropping temporary value in match in older editions pin!() has incorrect/unexpected drop order inside if-let.

AltStyle によって変換されたページ (->オリジナル) /