Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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

theemathas commented Aug 15, 2025

This code causes this PR to ICE in the dropping_copy_types lint:

pub fn foo() {
    drop(format_args!("a"));
}
Error output
thread 'rustc' panicked at /Users/timch/rust/compiler/rustc_errors/src/diagnostic.rs:960:9:
assertion `left == right` failed: Span must not be empty and have no suggestion
  left: Some(SubstitutionPart { span: src/lib.rs:2:27: 2:27 (#4), snippet: "" })
 right: None
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:697:5
   1: core::panicking::panic_fmt
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panicking.rs:75:14
   2: core::panicking::assert_failed_inner
   3: assert_failed<core::option::Option<&rustc_errors::SubstitutionPart>, core::option::Option<&rustc_errors::SubstitutionPart>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panicking.rs:403:5
   4: multipart_suggestion_with_style<(), rustc_error_messages::SubdiagMessage>
             at /Users/timch/rust/compiler/rustc_errors/src/diagnostic.rs:960:9
   5: add_to_diag<()>
             at /Users/timch/rust/compiler/rustc_lint/src/lints.rs:691:10
   6: subdiagnostic<(), rustc_lint::lints::UseLetUnderscoreIgnoreSuggestion>
             at /Users/timch/rust/compiler/rustc_errors/src/diagnostic.rs:1251:23
   7: decorate_lint
             at /Users/timch/rust/compiler/rustc_lint/src/lints.rs:719:10
   8: {closure#0}<rustc_lint::context::LateContext, rustc_span::span_encoding::Span, rustc_lint::lints::DropCopyDiag>
             at /Users/timch/rust/compiler/rustc_lint/src/context.rs:524:23
   9: call_once<rustc_lint::context::LintContext::emit_span_lint::{closure_env#0}<rustc_lint::context::LateContext, rustc_span::span_encoding::Span, rustc_lint::lints::DropCopyDiag>, (&mut rustc_errors::diagnostic::Diag<()>)>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/ops/function.rs:253:5
  10: call_once<(&mut rustc_errors::diagnostic::Diag<()>), dyn core::ops::function::FnOnce<(&mut rustc_errors::diagnostic::Diag<()>), Output=()>, alloc::alloc::Global>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/alloc/src/boxed.rs:1971:9
  11: lint_level_impl
             at /Users/timch/rust/compiler/rustc_middle/src/lint.rs:427:13
  12: lint_level<rustc_lint::context::LintContext::emit_span_lint::{closure_env#0}<rustc_lint::context::LateContext, rustc_span::span_encoding::Span, rustc_lint::lints::DropCopyDiag>>
             at /Users/timch/rust/compiler/rustc_middle/src/lint.rs:433:5
  13: node_span_lint<rustc_span::span_encoding::Span, rustc_lint::context::LintContext::emit_span_lint::{closure_env#0}<rustc_lint::context::LateContext, rustc_span::span_encoding::Span, rustc_lint::lints::DropCopyDiag>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:3177:9
  14: opt_span_lint<rustc_span::span_encoding::Span, rustc_lint::context::LintContext::emit_span_lint::{closure_env#0}<rustc_lint::context::LateContext, rustc_span::span_encoding::Span, rustc_lint::lints::DropCopyDiag>>
             at /Users/timch/rust/compiler/rustc_lint/src/context.rs:637:33
  15: emit_span_lint<rustc_lint::context::LateContext, rustc_span::span_encoding::Span, rustc_lint::lints::DropCopyDiag>
             at /Users/timch/rust/compiler/rustc_lint/src/context.rs:523:14
  16: check_expr
             at /Users/timch/rust/compiler/rustc_lint/src/drop_forget_useless.rs:184:24
  17: check_expr
             at /Users/timch/rust/compiler/rustc_lint/src/passes.rs:79:23
  18: {closure#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:33:14
  19: with_lint_attrs<rustc_lint::BuiltinCombinedModuleLateLintPass, rustc_lint::late::{impl#1}::visit_expr::{closure#0}::{closure_env#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:59:9
  20: {closure#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:165:18
  21: maybe_grow<(), rustc_lint::late::{impl#1}::visit_expr::{closure_env#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/stacker-0.1.21/src/lib.rs:57:9
  22: ensure_sufficient_stack<(), rustc_lint::late::{impl#1}::visit_expr::{closure_env#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/stack.rs:21:5
  23: visit_expr<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:164:9
  24: visit_stmt<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:179:9
  25: walk_block<rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_hir/src/intravisit.rs:694:5
  26: visit_block<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:240:9
  27: walk_expr<rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass>>
  28: {closure#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:167:17
  29: with_lint_attrs<rustc_lint::BuiltinCombinedModuleLateLintPass, rustc_lint::late::{impl#1}::visit_expr::{closure#0}::{closure_env#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:59:9
  30: {closure#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:165:18
  31: maybe_grow<(), rustc_lint::late::{impl#1}::visit_expr::{closure_env#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/stacker-0.1.21/src/lib.rs:57:9
  32: ensure_sufficient_stack<(), rustc_lint::late::{impl#1}::visit_expr::{closure_env#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/stack.rs:21:5
  33: visit_expr<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:164:9
  34: visit_body<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:120:9
  35: visit_nested_body<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:103:14
  36: visit_fn<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:196:9
  37: walk_item<rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_hir/src/intravisit.rs:558:32
  38: {closure#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:132:17
  39: with_param_env<rustc_lint::BuiltinCombinedModuleLateLintPass, rustc_lint::late::{impl#1}::visit_item::{closure#0}::{closure_env#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:71:9
  40: {closure#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:130:16
  41: with_lint_attrs<rustc_lint::BuiltinCombinedModuleLateLintPass, rustc_lint::late::{impl#1}::visit_item::{closure_env#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:59:9
  42: visit_item<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:129:14
  43: visit_nested_item<rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_hir/src/intravisit.rs:249:29
  44: walk_mod<rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_hir/src/intravisit.rs:650:5
  45: process_mod<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:77:9
  46: {closure#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:399:12
  47: with_lint_attrs<rustc_lint::BuiltinCombinedModuleLateLintPass, rustc_lint::late::late_lint_mod_inner::{closure_env#0}<rustc_lint::BuiltinCombinedModuleLateLintPass>>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:59:9
  48: late_lint_mod_inner<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:393:8
  49: late_lint_mod<rustc_lint::BuiltinCombinedModuleLateLintPass>
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:367:13
  50: lint_mod
             at /Users/timch/rust/compiler/rustc_lint/src/lib.rs:151:5
  51: {closure#0}
             at /Users/timch/rust/compiler/rustc_query_impl/src/plumbing.rs:294:9
      [... omitted 33 frames ...]
  52: query_ensure<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 0]>>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:198:9
  53: lint_mod
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:233:9
  54: {closure#0}
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:474:70
  55: {closure#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_middle/src/hir/map.rs:476:13
  56: {closure#0}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:181:30
  57: call_once<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panic/unwind_safe.rs:272:9
  58: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:589:40
  59: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:552:19
  60: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panic.rs:359:14
  61: run<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:23:9
  62: {closure#1}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:181:23
  63: for_each<rustc_hir::hir_id::OwnerId, rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure_env#1}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/slice/iter/macros.rs:277:21
  64: {closure#0}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:180:27
  65: parallel_guard<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure_env#0}<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:39:15
  66: par_for_each_in<&rustc_hir::hir_id::OwnerId, &[rustc_hir::hir_id::OwnerId], rustc_middle::hir::map::{impl#3}::par_hir_for_each_module::{closure_env#0}<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:175:5
  67: par_hir_for_each_module<rustc_lint::late::check_crate::{closure#1}::{closure#0}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_middle/src/hir/map.rs:475:9
  68: {closure#0}
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:474:21
  69: run<(), rustc_lint::late::check_crate::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/profiling.rs:844:9
  70: time<(), rustc_lint::late::check_crate::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_session/src/utils.rs:16:50
  71: {closure#1}
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:472:22
  72: call_once<(), rustc_lint::late::check_crate::{closure_env#1}>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panic/unwind_safe.rs:272:9
  73: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_lint::late::check_crate::{closure_env#1}>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:589:40
  74: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_lint::late::check_crate::{closure_env#1}>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:552:19
  75: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_lint::late::check_crate::{closure_env#1}>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panic.rs:359:14
  76: run<(), rustc_lint::late::check_crate::{closure_env#1}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:23:9
  77: {closure#0}<rustc_lint::late::check_crate::{closure_env#0}, rustc_lint::late::check_crate::{closure_env#1}, (), ()>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:53:23
  78: parallel_guard<(core::option::Option<()>, core::option::Option<()>), rustc_data_structures::sync::parallel::serial_join::{closure_env#0}<rustc_lint::late::check_crate::{closure_env#0}, rustc_lint::late::check_crate::{closure_env#1}, (), ()>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:39:15
  79: serial_join<rustc_lint::late::check_crate::{closure_env#0}, rustc_lint::late::check_crate::{closure_env#1}, (), ()>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:51:18
  80: join<rustc_lint::late::check_crate::{closure_env#0}, rustc_lint::late::check_crate::{closure_env#1}, (), ()>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:132:9
  81: check_crate
             at /Users/timch/rust/compiler/rustc_lint/src/late.rs:464:5
  82: {closure#0}
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1165:29
  83: run<(), rustc_interface::passes::analysis::{closure#0}::{closure#2}::{closure#0}::{closure#2}::{closure#1}::{closure#0}::{closure#2}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/profiling.rs:844:9
  84: time<(), rustc_interface::passes::analysis::{closure#0}::{closure#2}::{closure#0}::{closure#2}::{closure#1}::{closure#0}::{closure#2}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_session/src/utils.rs:16:50
  85: {closure#2}
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1164:30
  86: call_once<(), rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure#0}::{closure#0}::{closure_env#2}>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panic/unwind_safe.rs:272:9
  87: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure#0}::{closure#0}::{closure_env#2}>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:589:40
  88: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure#0}::{closure#0}::{closure_env#2}>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:552:19
  89: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure#0}::{closure#0}::{closure_env#2}>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panic.rs:359:14
  90: run<(), rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure#0}::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:23:9
  91: {closure#0}
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:88:29
  92: parallel_guard<(), rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure#0}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:39:15
  93: {closure#0}
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1152:17
  94: call_once<(), rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure_env#0}>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panic/unwind_safe.rs:272:9
  95: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure_env#0}>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:589:40
  96: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure_env#0}>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:552:19
  97: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure_env#0}>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panic.rs:359:14
  98: run<(), rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:23:9
  99: {closure#1}
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:87:27
 100: parallel_guard<(), rustc_interface::passes::analysis::{closure#0}::{closure_env#1}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:39:15
 101: {closure#0}
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1148:9
 102: run<(), rustc_interface::passes::analysis::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/profiling.rs:844:9
 103: time<(), rustc_interface::passes::analysis::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_session/src/utils.rs:16:50
 104: analysis
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1147:10
 105: {closure#0}
             at /Users/timch/rust/compiler/rustc_query_impl/src/plumbing.rs:294:9
      [... omitted 33 frames ...]
 106: query_ensure<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:198:9
 107: analysis
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:233:9
 108: {closure#2}
             at /Users/timch/rust/compiler/rustc_driver_impl/src/lib.rs:370:29
 109: {closure#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1006:27
 110: {closure#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1546:37
 111: {closure#0}<rustc_middle::ty::context::{impl#21}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context/tls.rs:60:9
 112: try_with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#21}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/thread/local.rs:315:12
 113: with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#21}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/thread/local.rs:279:20
 114: enter_context<rustc_middle::ty::context::{impl#21}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context/tls.rs:57:9
 115: enter<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1546:9
 116: create_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1751:13
 117: {closure#2}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:973:9
 118: call_once<rustc_interface::passes::create_and_enter_global_ctxt::{closure_env#2}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, (&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy, alloc::alloc::Global>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2})>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/ops/function.rs:253:5
 119: call_once<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy, alloc::alloc::Global>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}), dyn core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy, alloc::alloc::Global>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}), Output=core::option::Option<rustc_interface::queries::Linker>>, alloc::alloc::Global>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/alloc/src/boxed.rs:1971:9
 120: create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1014:5
 121: {closure#0}
             at /Users/timch/rust/compiler/rustc_driver_impl/src/lib.rs:343:22
 122: {closure#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_interface/src/interface.rs:525:80
 123: call_once<(), rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panic/unwind_safe.rs:272:9
 124: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:589:40
 125: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:552:19
 126: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>, ()>
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panic.rs:359:14
 127: {closure#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_interface/src/interface.rs:525:23
 128: {closure#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>
             at /Users/timch/rust/compiler/rustc_interface/src/util.rs:199:17
 129: {closure#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>
             at /Users/timch/rust/compiler/rustc_interface/src/util.rs:153:24
 130: set<rustc_span::SessionGlobals, rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}::{closure_env#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>, ()>
             at /Users/timch/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/scoped-tls-1.0.1/src/lib.rs:137:9
 131: create_session_globals_then<(), rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}::{closure_env#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>>
             at /Users/timch/rust/compiler/rustc_span/src/lib.rs:146:21
 132: {closure#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>
             at /Users/timch/rust/compiler/rustc_interface/src/util.rs:149:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/timch/foo/rustc-ice-2025-08-15T06_05_34-7312.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `foo` (lib)

Caused by:
  process didn't exit successfully: `/Users/timch/.rustup/toolchains/stage1/bin/rustc --crate-name foo --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=72 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=8c501619d3290ba0 -C extra-filename=-24fb7592114348d8 --out-dir /Users/timch/foo/target/debug/deps -C incremental=/Users/timch/foo/target/debug/incremental -L dependency=/Users/timch/foo/target/debug/deps` (exit status: 101)

@dianne
Copy link
Contributor Author

dianne commented Aug 15, 2025

Thanks for testing this! That's also a separate bug; it ICEs with debug asserts on before my commits. Here's what it looks like on stable/nightly with debug asserts off:

help: use `let _ = ...` to ignore the expression or result
  |
2 -     drop(format_args!("a"));
2 +     drop(let _ = );
  |

Edit: To make sure there's no interaction, I've recompiled this PR with debug asserts off and am getting the drop(let _ = ); suggestion instead of ICE. I'm not sure if there's a way to test non-regression there in CI though; rebasing onto a fix for that bug would work, but that should probably be kept out of a hypothetical backport.

@craterbot
Copy link
Collaborator

🎉 Experiment pr-145342 is completed!
📊 3 regressed and 6 fixed (681861 total)
📰 Open the summary report.

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

@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 16, 2025
@theemathas
Copy link
Contributor

The crater run is clean. No relevant regressions or fixes.

@theemathas
Copy link
Contributor

theemathas commented Aug 16, 2025

Summary of everything so far

I am naming each of the regressions: A, B, C, D, so it's easier to refer to them in the future. For each of them, I give a link to a reproducer of the bug, and I describe when the regression occurred, the prerequisites for code to be affected by the bug, the likelihood (in my opinion) of real user code being affected, and the impact of the bug on such code.

Additionally, there's:

@dianne
Copy link
Contributor Author

dianne commented Aug 16, 2025

With regard to regression D, I imagine it affects edition 2024 as well for match arms where the arm body isn't wrapped in a block expression. It's caused by #143376 extending the surface area of the bug underlying regressions A/B to all match arms with guards where the super let-based macro isn't wrapped in a more deeply nested temporary destruction scope (e.g. a block tail expression in edition 2024). I'm sure you can also get a silent miscompile out of it if you're relying on things like temporary drop order for tuple constructor expressions and constructing a tuple with a write! call in it, but that feels unlikely in real code.

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Aug 19, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Aug 19, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Aug 19, 2025
@Amanieu
Copy link
Member

Amanieu commented Aug 19, 2025

We discussed this in the @rust-lang/libs-api meeting and we're happy to defer to lang for this issue.

@traviscross traviscross removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-0 Lang team prioritization drag level 0.https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang. labels Aug 20, 2025
@apiraino
Copy link
Contributor

apiraino commented Aug 21, 2025

Stable backport declined as per compiler team on Zulip.

We reviewed again the stable backport and our concerns still stand.

@rustbot label -stable-nominated

@rustbot rustbot removed the stable-nominated Nominated for backporting to the compiler in the stable channel. label Aug 21, 2025
@jieyouxu

This comment was marked as off-topic.

@craterbot

This comment was marked as off-topic.

@jieyouxu

This comment was marked as off-topic.

@craterbot

This comment was marked as off-topic.

@jieyouxu
Copy link
Member

@craterbot
Copy link
Collaborator

👌 Experiment pr-145342-1 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 23, 2025
@dianne
Copy link
Contributor Author

dianne commented Aug 23, 2025

Something to consider for the FCP: this PR does not make the identity in #145342 (comment) hold. See #145784 (comment) for how it fails to hold in non-extending expressions, due to super let extending the lifetimes of its initializer's temporaries, effectively ignoring block tail expressions' temporary drop scopes. If we want that identity, I think we'd need to rework non-extended super let to have more restrictive temporary lifetime extension rules. Alternatively, whatever identity is used for reasoning about super let may need to account for it having differing meanings in different contexts.

My personal judgment is that that issue is orthogonal to the bug this PR fixes: this PR fixes super let's bindings' lifetimes, whereas the identity fails to hold in non-extending expressions due to super let's initializer's temporaries' lifetimes. However, if the FCP is for super let behaving a particular way, then this PR alone doesn't achieve that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. 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. T-lang Relevant to the language team
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.