Skip to content

Conversation

dianne
Copy link
Contributor

@dianne dianne commented Aug 13, 2025

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

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.
@rustbot
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
@compiler-errors
Copy link
Member

@dianne does this need crater?

@traviscross
Copy link
Contributor

traviscross commented Aug 13, 2025

@bors2 try

@craterbot

This comment was marked as resolved.

@rust-bors

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`
@rust-bors
Copy link

rust-bors bot commented Aug 13, 2025

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

@compiler-errors
Copy link
Member

@craterbot check

@craterbot
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.

ℹ️ 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
@theemathas
Copy link
Contributor

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

@dianne
Copy link
Contributor Author

dianne commented Aug 14, 2025

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.

@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
@wesleywiser
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
@rust-rfcbot
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.

@fee1-dead
Copy link
Member

r? rust-lang/compiler

@rustbot rustbot assigned nnethercote and unassigned fee1-dead Sep 1, 2025
@nnethercote
Copy link
Contributor

@bors r+

@bors
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
@dianne dianne deleted the if-let-super-let branch September 4, 2025 10:28
@apiraino
Copy link
Contributor

apiraino commented Sep 4, 2025

Beta backport declined as per compiler team on Zulip, we judge the backport a bit risky due to being about 2 weeks away from the new release.

@rustbot label -beta-nominated

@rustbot rustbot removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Sep 4, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 5, 2025
Rollup of 24 pull requests

Successful merges:

 - rust-lang/rust#140459 (Add `read_buf` equivalents for positioned reads)
 - rust-lang/rust#143725 (core: add Peekable::next_if_map)
 - rust-lang/rust#145209 (Stabilize `path_add_extension`)
 - rust-lang/rust#145342 (fix drop scope for `super let` bindings within `if let`)
 - rust-lang/rust#145750 (raw_vec.rs: Remove superfluous fn alloc_guard)
 - rust-lang/rust#145827 (On unused binding or binding not present in all patterns, suggest potential typo of unit struct/variant or const)
 - rust-lang/rust#145932 (Allow `inline(always)` with a target feature behind a unstable feature `target_feature_inline_always`.)
 - rust-lang/rust#145962 (Ensure we emit an allocator shim when only some crate types need one)
 - rust-lang/rust#145963 (Add LSX accelerated implementation for source file analysis)
 - rust-lang/rust#146054 (add `#[must_use]` to `array::repeat`)
 - rust-lang/rust#146090 (Derive `PartialEq` for `InvisibleOrigin`)
 - rust-lang/rust#146112 (don't uppercase error messages)
 - rust-lang/rust#146120 (Correct typo in `rustc_errors` comment)
 - rust-lang/rust#146124 (Test `rustc-dev` in `distcheck`)
 - rust-lang/rust#146127 (Rename `ToolRustc` to `ToolRustcPrivate`)
 - rust-lang/rust#146131 (rustdoc-search: add test case for indexing every item type)
 - rust-lang/rust#146134 (llvm: nvptx: Layout update to match LLVM)
 - rust-lang/rust#146136 (docs(std): add missing closing code block fences in doc comments)
 - rust-lang/rust#146137 (Disallow frontmatter in `--cfg` and `--check-cfg` arguments)
 - rust-lang/rust#146140 (compiletest: cygwin follows windows in using PATH for dynamic libraries)
 - rust-lang/rust#146150 (fix(rustdoc): match rustc `--emit` precedence )
 - rust-lang/rust#146155 (Make bootstrap self test parallel)
 - rust-lang/rust#146161 ([rustdoc] Uncomment code to add scraped rustdoc examples in loaded paths)
 - rust-lang/rust#146172 (triagebot: configure some pings when certain attributes are used)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
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.