Skip to content

Guard patterns: MIR lowering#154545

Draft
Human9000-bit wants to merge 13 commits intorust-lang:mainfrom
Human9000-bit:guard-patterns-mir
Draft

Guard patterns: MIR lowering#154545
Human9000-bit wants to merge 13 commits intorust-lang:mainfrom
Human9000-bit:guard-patterns-mir

Conversation

@Human9000-bit
Copy link
Copy Markdown
Contributor

@Human9000-bit Human9000-bit commented Mar 29, 2026

View all comments

This pr implements THIR -> MIR lowering of guard patterns:

  • When PatKind::Guard is encountered, we lower the subpattern and push ExprId of a condition to extra_data.guard_patterns in order-preserving manner
  • Then we pass that field to MatchTreeSubBranch
  • In bind_ang_guard_matched_candidate we merge arm and guard patterns into a single Vec<Exprid>
  • Then we iterate over that vec of guards and merge them in a chain at MIR level

r? @dianne
cc @Nadrieril, @max-niederman

Tracking issue: #129967

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 29, 2026

Some changes occurred in match lowering

cc @Nadrieril

@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 Mar 29, 2026
@rust-log-analyzer

This comment has been minimized.

@Zalathar
Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 29, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 29, 2026
@Human9000-bit
Copy link
Copy Markdown
Contributor Author

@Zalathar could you schedule perf run once again?

@Zalathar
Copy link
Copy Markdown
Member

It’ll be faster to just let the old try job keep running. The new changes shouldn’t affect perf, so I think benchmarking the current job will be fine.

Copy link
Copy Markdown
Contributor

@dianne dianne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need some //@ run-pass tests to make sure the runtime semantics are correct, possibly also with //@ compile-flags: -Zvalidate-mir -Zlint-mir to help catch drop scheduling bugs. Getting scoping right and scheduling drops properly for guard patterns in all cases is a little subtle and will end up being the trickiest part of this; I know my first stab at that produced broken MIR ^^

You'll also want to look into how fake borrows work; patterns with guards on them will need fake borrows to make sure the guards can't modify any places being tested. For match and irrefutable let, this is needed for soundness (and in other cases, we should probably be consistent with that). At a glance, it doesn't look like this is setting has_guard for candidates, so certain things like fake borrows won't work. Likewise, this will need tests. I think some other things might use has_guard too, like or-pattern simplification.

As a meta note, I do have some opinions about how guard patterns should be implemented from my own attempt at lowering them to MIR last year. I'll try not just to compare this to what I'd do, since I'd effectively be reviewing my own code, but it might help to have more eyes on it just in case.

View changes since this review

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 29, 2026

☀️ Try build successful (CI)
Build commit: 94df5ce (94df5ce4eb9a637adba2da13b3f79cf010e61aeb, parent: 584d32e3ee7a2051c9ec1338d259ed8ef16380ca)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (94df5ce): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary 2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.0% [0.8%, 3.5%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.6% [2.6%, 2.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.6% [2.6%, 2.6%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 484.385s -> 484.355s (-0.01%)
Artifact size: 394.81 MiB -> 394.86 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 29, 2026
@Human9000-bit
Copy link
Copy Markdown
Contributor Author

@dianne, just asking: in your local implementation, what were the signs of incorrect scoping and drop scheduling?

@theemathas
Copy link
Copy Markdown
Contributor

theemathas commented Mar 30, 2026

(Note: I had to merge this PR with the main branch locally before compiling, to work around #154408. So, line numbers might not be accurate.)

This code causes an ICE with this PR:

#![feature(guard_patterns)]

fn main() {
    let x = String::from("abc");
    match x {
        (y if false) | y => {}
        _ => {}
    }
}
Error output
warning: the feature `guard_patterns` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/main.rs:1:12
  |
1 | #![feature(guard_patterns)]
  |            ^^^^^^^^^^^^^^
  |
  = note: see issue #129967 <https://github.com/rust-lang/rust/issues/129967> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: unreachable pattern
 --> src/main.rs:6:24
  |
6 |         (y if false) | y => {}
  |          -             ^ no value can reach this
  |          |
  |          matches any value
  |
  = note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default

warning: unreachable pattern
 --> src/main.rs:7:9
  |
6 |         (y if false) | y => {}
  |         ---------------- matches all the relevant values
7 |         _ => {}
  |         ^ no value can reach this

error: internal compiler error: compiler/rustc_mir_build/src/builder/mod.rs:386:17: anything with one local should never be within a guard.


thread 'rustc' (205910) panicked at compiler/rustc_mir_build/src/builder/mod.rs:386:17:
Box<dyn Any>
stack backtrace:
   0: begin_panic<rustc_errors::ExplicitBug>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panicking.rs:761:5
   1: panic_any<rustc_errors::ExplicitBug>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panic.rs:260:5
   2: emit_producing_guarantee
             at /Users/timch/rust/compiler/rustc_errors/src/diagnostic.rs:58:9
   3: emit<rustc_errors::diagnostic::BugAbort>
             at /Users/timch/rust/compiler/rustc_errors/src/diagnostic.rs:1285:9
   4: bug<alloc::string::String>
             at /Users/timch/rust/compiler/rustc_errors/src/lib.rs:927:30
   5: {closure#0}<rustc_span::span_encoding::Span>
             at /Users/timch/rust/compiler/rustc_middle/src/util/bug.rs:39:48
   6: {closure#0}<rustc_middle::util::bug::opt_span_bug_fmt::{closure_env#0}<rustc_span::span_encoding::Span>, !>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context/tls.rs:109:23
   7: with_context_opt<rustc_middle::ty::context::tls::with_opt::{closure_env#0}<rustc_middle::util::bug::opt_span_bug_fmt::{closure_env#0}<rustc_span::span_encoding::Span>, !>, !>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context/tls.rs:75:18
   8: with_opt<rustc_middle::util::bug::opt_span_bug_fmt::{closure_env#0}<rustc_span::span_encoding::Span>, !>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context/tls.rs:107:5
   9: opt_span_bug_fmt<rustc_span::span_encoding::Span>
             at /Users/timch/rust/compiler/rustc_middle/src/util/bug.rs:33:5
  10: bug_fmt
             at /Users/timch/rust/compiler/rustc_middle/src/util/bug.rs:16:5
  11: local_id
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/mod.rs:386:17
  12: var_local_id
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/mod.rs:257:31
  13: storage_live_binding
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/matches/mod.rs:786:29
  14: bind_matched_candidate_for_guard<core::slice::iter::Iter<rustc_mir_build::builder::matches::Binding>>
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/matches/mod.rs:2687:38
  15: bind_and_guard_matched_candidate
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/matches/mod.rs:2451:18
  16: bind_pattern
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/matches/mod.rs:557:40
  17: {closure#1}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/matches/mod.rs:464:46
  18: opt_in_scope<(), rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure#1}::{closure#1}::{closure_env#1}>
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/scope.rs:717:13
  19: {closure#1}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/matches/mod.rs:437:26
  20: in_scope<rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure#1}::{closure_env#1}, ()>
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/scope.rs:700:34
  21: {closure#1}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/matches/mod.rs:436:22
  22: {closure#0}<(&rustc_middle::thir::Arm, rustc_mir_build::builder::matches::MatchTreeBranch), rustc_middle::mir::BasicBlock, (), rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}, core::iter::traits::iterator::Iterator::for_each::call::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::vec::{impl#21}::extend_trusted::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::alloc::Global, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/iter/adapters/map.rs:88:28
  23: spec_fold<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>, (), core::iter::adapters::map::map_fold::{closure_env#0}<(&rustc_middle::thir::Arm, rustc_mir_build::builder::matches::MatchTreeBranch), rustc_middle::mir::BasicBlock, (), rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}, core::iter::traits::iterator::Iterator::for_each::call::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::vec::{impl#21}::extend_trusted::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::alloc::Global, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>>>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/iter/adapters/zip.rs:678:25
  24: fold<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>, (), core::iter::adapters::map::map_fold::{closure_env#0}<(&rustc_middle::thir::Arm, rustc_mir_build::builder::matches::MatchTreeBranch), rustc_middle::mir::BasicBlock, (), rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}, core::iter::traits::iterator::Iterator::for_each::call::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::vec::{impl#21}::extend_trusted::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::alloc::Global, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>>>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/iter/adapters/zip.rs:248:9
  25: fold<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>, (), core::iter::adapters::map::map_fold::{closure_env#0}<(&rustc_middle::thir::Arm, rustc_mir_build::builder::matches::MatchTreeBranch), rustc_middle::mir::BasicBlock, (), rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}, core::iter::traits::iterator::Iterator::for_each::call::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::vec::{impl#21}::extend_trusted::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::alloc::Global, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>>>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/iter/adapters/zip.rs:103:9
  26: fold<rustc_middle::mir::BasicBlock, core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}, (), core::iter::traits::iterator::Iterator::for_each::call::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::vec::{impl#21}::extend_trusted::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::alloc::Global, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/iter/adapters/map.rs:128:19
  27: for_each<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>, alloc::vec::{impl#21}::extend_trusted::{closure_env#0}<rustc_middle::mir::BasicBlock, alloc::alloc::Global, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/iter/traits/iterator.rs:845:14
  28: extend_trusted<rustc_middle::mir::BasicBlock, alloc::alloc::Global, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/alloc/src/vec/mod.rs:4001:26
  29: spec_extend<rustc_middle::mir::BasicBlock, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>, alloc::alloc::Global>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/alloc/src/vec/spec_extend.rs:27:14
  30: from_iter<rustc_middle::mir::BasicBlock, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/alloc/src/vec/spec_from_iter_nested.rs:60:16
  31: from_iter<rustc_middle::mir::BasicBlock, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/alloc/src/vec/spec_from_iter.rs:33:9
  32: from_iter<rustc_middle::mir::BasicBlock, core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/alloc/src/vec/mod.rs:3865:9
  33: collect<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::thir::ArmId>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#0}>, alloc::vec::into_iter::IntoIter<rustc_mir_build::builder::matches::MatchTreeBranch, alloc::alloc::Global>>, rustc_mir_build::builder::matches::{impl#0}::lower_match_arms::{closure_env#1}>, alloc::vec::Vec<rustc_middle::mir::BasicBlock, alloc::alloc::Global>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/iter/traits/iterator.rs:2064:9
  34: lower_match_arms
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/matches/mod.rs:483:14
  35: match_expr
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/matches/mod.rs:382:14
  36: expr_into_dest
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/expr/into.rs:60:65
  37: {closure#0}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/expr/into.rs:53:30
  38: in_scope<rustc_mir_build::builder::expr::into::{impl#0}::expr_into_dest::{closure#0}::{closure_env#0}, ()>
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/scope.rs:700:34
  39: {closure#0}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/expr/into.rs:52:26
  40: maybe_grow<rustc_mir_build::builder::BlockAnd<()>, rustc_mir_build::builder::expr::into::{impl#0}::expr_into_dest::{closure_env#0}>
             at /Users/timch/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/stacker-0.1.21/src/lib.rs:57:9
  41: ensure_sufficient_stack<rustc_mir_build::builder::BlockAnd<()>, rustc_mir_build::builder::expr::into::{impl#0}::expr_into_dest::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/stack.rs:21:5
  42: expr_into_dest
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/expr/into.rs:51:17
  43: ast_block_stmts
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/block.rs:324:26
  44: {closure#0}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/block.rs:29:22
  45: in_scope<rustc_mir_build::builder::block::{impl#0}::ast_block::{closure_env#0}, ()>
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/scope.rs:700:34
  46: ast_block
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/block.rs:23:14
  47: expr_into_dest
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/expr/into.rs:58:22
  48: {closure#0}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/expr/into.rs:53:30
  49: in_scope<rustc_mir_build::builder::expr::into::{impl#0}::expr_into_dest::{closure#0}::{closure_env#0}, ()>
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/scope.rs:700:34
  50: {closure#0}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/expr/into.rs:52:26
  51: maybe_grow<rustc_mir_build::builder::BlockAnd<()>, rustc_mir_build::builder::expr::into::{impl#0}::expr_into_dest::{closure_env#0}>
             at /Users/timch/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/stacker-0.1.21/src/lib.rs:57:9
  52: ensure_sufficient_stack<rustc_mir_build::builder::BlockAnd<()>, rustc_mir_build::builder::expr::into::{impl#0}::expr_into_dest::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/stack.rs:21:5
  53: expr_into_dest
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/expr/into.rs:51:17
  54: args_and_body
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/mod.rs:1158:18
  55: {closure#0}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/mod.rs:539:29
  56: in_scope<rustc_mir_build::builder::construct_fn::{closure#3}::{closure#0}::{closure_env#0}, ()>
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/scope.rs:700:34
  57: {closure#0}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/mod.rs:538:30
  58: in_breakable_scope<rustc_mir_build::builder::construct_fn::{closure#3}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/scope.rs:556:33
  59: {closure#3}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/mod.rs:537:14
  60: in_scope<rustc_mir_build::builder::construct_fn::{closure_env#3}, ()>
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/scope.rs:700:34
  61: construct_fn
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/mod.rs:532:35
  62: {closure#0}
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/mod.rs:83:45
  63: build_mir_inner_impl
             at /Users/timch/rust/compiler/rustc_mir_build/src/builder/mod.rs:92:13
  64: build_mir_inner_impl
             at /Users/timch/rust/compiler/rustc_middle/src/hooks/mod.rs:24:17
  65: mir_built
             at /Users/timch/rust/compiler/rustc_mir_transform/src/lib.rs:390:24
      [... omitted 28 frames ...]
  66: query_ensure_ok_or_done<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/inner.rs:63:13
  67: mir_built<rustc_span::def_id::LocalDefId>
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:635:21
  68: check_unsafety
             at /Users/timch/rust/compiler/rustc_mir_build/src/check_unsafety.rs:1153:23
      [... omitted 28 frames ...]
  69: check_unsafety<rustc_span::def_id::LocalDefId>
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:601:21
  70: {closure#0}
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1142:33
  71: {closure#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_middle/src/hir/map.rs:340:79
  72: {closure#0}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:175:30
  73: call_once<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/panic/unwind_safe.rs:274:9
  74: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>>, ()>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panicking.rs:581:40
  75: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panicking.rs:544:19
  76: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>>, ()>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panic.rs:359:14
  77: run<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:23:9
  78: {closure#1}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:175:23
  79: for_each<rustc_span::def_id::LocalDefId, rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure_env#1}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/slice/iter/macros.rs:301:21
  80: {closure#0}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:174:27
  81: parallel_guard<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure_env#0}<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:39:15
  82: par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], rustc_middle::hir::map::{impl#3}::par_hir_body_owners::{closure_env#0}<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:169:5
  83: par_hir_body_owners<rustc_interface::passes::run_required_analyses::{closure#2}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_middle/src/hir/map.rs:340:9
  84: {closure#2}
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1138:13
  85: run<(), rustc_interface::passes::run_required_analyses::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/profiling.rs:845:9
  86: time<(), rustc_interface::passes::run_required_analyses::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_session/src/utils.rs:17:50
  87: run_required_analyses
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1137:10
  88: analysis
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1181:5
      [... omitted 28 frames ...]
  89: query_ensure_ok_or_done<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/inner.rs:63:13
  90: analysis
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:601:21
  91: {closure#2}
             at /Users/timch/rust/compiler/rustc_driver_impl/src/lib.rs:325:29
  92: {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:1022:23
  93: {closure#1}<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}>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:863:37
  94: {closure#0}<rustc_middle::ty::context::{impl#19}::enter::{closure_env#1}<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}>, 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:56:9
  95: try_with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#19}::enter::{closure_env#1}<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}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/thread/local.rs:513:12
  96: with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#19}::enter::{closure_env#1}<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}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/thread/local.rs:477:20
  97: enter_context<rustc_middle::ty::context::{impl#19}::enter::{closure_env#1}<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}>, 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:53:9
  98: enter<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}>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:863:9
  99: create_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, 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}>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1068:13
 100: 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:989:5
 101: {closure#0}
             at /Users/timch/rust/compiler/rustc_driver_impl/src/lib.rs:298:22
 102: {closure#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_interface/src/interface.rs:500:80
 103: call_once<(), rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/panic/unwind_safe.rs:274:9
 104: 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/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panicking.rs:581:40
 105: 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/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panicking.rs:544:19
 106: 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/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panic.rs:359:14
 107: {closure#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_interface/src/interface.rs:500:23
 108: {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:203:17
 109: {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:159:24
 110: 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
 111: 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:153:21
 112: {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:155:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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-2026-03-30T08_00_41-14079.txt` to your bug report

note: rustc 1.96.0-dev running on aarch64-apple-darwin

note: compiler flags: --crate-type bin -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 [mir_built] building MIR for `main`
#1 [check_unsafety] unsafety-checking `main`
#2 [analysis] running analysis passes on crate `foo`
end of query stack
warning: `foo` (bin "foo") generated 3 warnings
error: could not compile `foo` (bin "foo"); 3 warnings emitted

Caused by:
  process didn't exit successfully: `/Users/timch/.rustup/toolchains/stage1/bin/rustc --crate-name foo --edition=2024 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=70 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=74fbbc1e3db03153 -C extra-filename=-45ca759c633b2da6 --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)

The following code compiles without errors with this PR, and causes a SIGTRAP at run time.

#![feature(guard_patterns)]

fn main() -> ! {
    let (_ if panic!()) = 1;
}

The following code compiles without error with this PR and prints "abc" at run time.

#![feature(guard_patterns)]

fn main() {
    let x = String::from("abc");
    let (y if false) = x;
    println!("{y}");
}

@dianne
Copy link
Copy Markdown
Contributor

dianne commented Mar 30, 2026

in your local implementation, what were the signs of incorrect scoping and drop scheduling?

iirc StorageDeads weren't being emitted properly for RefForGuard bindings for guard patterns in if let, let, and/or function parameters. Putting -Zlint-mir on all my tests was what caught that. Some of those tests were for for runtime drop order, so it's possible that those failing for if let, let, or function parameters was also a sign.

I can also give more direction on how these things work, where to look, etc., if you'd like ^^ I'm new to mentoring, so I'm not sure what balance would be best there; please let me know!

The following code compiles without errors with this PR, and causes a SIGTRAP at run time.

The following code compiles without error with this PR and prints "abc" at run time.

Oh, that's kind of worrying. Is exhaustiveness not checked at all for guard patterns currently? Having at least a stopgap for that could be good. Neither of those should compile, of course, but it should be exhaustiveness checking's responsibility, not MIR lowering.

Edit: yeah, it looks like exhaustiveness wasn't part of #153828. That's fine; guard patterns are a work in progress. But it probably should be tackled in its own PR, not here.

@theemathas
Copy link
Copy Markdown
Contributor

This code compiles and prints 1, and generates a strange warning.

#![feature(guard_patterns)]
#![expect(unused_parens)]

fn main() {
    let x = (true, 1);
    match x {
        (true, ((y @ 1) | (y @ 1)) if false) => {
            println!("{y}");
        }
        _ => {}
    }
}
warning: unreachable pattern
 --> src/main.rs:7:32
  |
7 |         (true, ((y @ 1) | (y @ 1)) if false) => {
  |                      -         ^ no value can reach this
  |                      |
  |                      matches all the relevant values
  |
  = note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default

@Human9000-bit
Copy link
Copy Markdown
Contributor Author

Human9000-bit commented Mar 30, 2026

Thanks, @theemathas, for feedback
FYI this one causes SIGILL:

#![feature(guard_patterns)]
#![allow(incomplete_features)]

fn main() {
    generic_usage(true, false, true);
}

fn generic_usage(x: bool, y: bool, z: bool) -> bool {
    match (x, y) {
        (true if z, false if !z) => true,
        (false if z, true if z) => false,
        (true, true) => true,
        (false, false) => false
    }
}

@Human9000-bit

This comment was marked as off-topic.

@Human9000-bit Human9000-bit marked this pull request as draft March 30, 2026 09:26
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 30, 2026
@rust-log-analyzer

This comment has been minimized.

Comment on lines +649 to +651

#[type_visitable(ignore)]
pub scope: Option<region::Scope>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this is included for each pattern node? Guard expressions should already have scope information on them (since all expressions can be associated to their temporary scopes), and the scope to return to when a guard fails can probably be the same for the whole match.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean taking ItemLocalId from expression from guards is fine?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the individual guards' ItemLocalIds shouldn't matter for guard pattern lowering. You shouldn't have to consider them when picking what scope to use for the in_if_then_scope call. The scope provided to in_if_then_scope is the scope to return to on guard failure; i.e., failing a guard leaves all the scopes nested within that chosen scope, dropping their contents. When a guard fails, we need to drop the bindings created for the guard, so the chosen scope should be above the scope of the match arm's bindings, which itself should be above the guards' scopes. This is why, for match, the scope of the match expression is used; it's the scope above the arms' scopes (which contain the arms' bindings).

Comment on lines +973 to +974
/// Scope of this sub-branch
scope: Option<Scope>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope to return to when a guard fails can be the same for the entire match, I think? I don't think it needs to vary per sub-branch.

Comment on lines +1437 to +1438
/// Scope of this sub-branch; used mostly by guard patterns
scope: Option<Scope>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, I don't think this needs to vary per sub-branch?

Comment on lines +455 to +459
// In some cases during MIR lowering we need a Scope
let scope = region::Scope {
local_id: pat.hir_id.local_id,
data: region::ScopeData::MatchGuard,
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use a scope, you'll also need to enter the same scope while building the MIR; I think that's what the ICEs in PR CI are about. You should also create the scope in the scope resolution visitor, since that should match up with MIR building. As above, though, I don't think should be on every guard pattern.

There's meant to be exactly one ScopeData::MatchGuard per match arm with a guard, nested within the arm's scope; it's used for if let guard bindings and temporaries so that they're dropped before the arm's pattern's bindings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. How to enter a scope in MIR build? Like, self.in_scope()?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. When the MIR builder leaves a scope (by getting to the end of the closure provided to Builder::in_scope), it emits the drops that were scheduled in that scope (i.e. the drops for locals in that scope). As such, it's important for the MIR builder to enter the scopes of whatever it's lowering at the appropriate times.

These things are kind of spread out, so here's a couple examples:

Expressions, statements, etc. have an associated ScopeData::Node scope:

  • This is created for all applicable nodes by the scope resolution visitor here.
  • This is included in the THIR for each HIR expression here by wrapping the THIR for each HIR expression in an ExprKind::Scope.
  • The various places during MIR building that handle expressions call Builder::in_scope on that scope when they encounter an ExprKind::Scope.

For match, in addition to the scope for the whole match expression, match arms also each have a scope for the arm. If an arm has a guard, there's also a scope for the guard bindings and temporaries nested within that (which extends through the arm body, so that if let guards' bindings and temps live through the arm):

  • The scope resolution visitor sets up those scopes here when determining scopes for bindings and temporaries in match arms.
  • This is mirrored in MIR building here; we enter those scopes before lowering the arms, so that we can schedule drops for bindings and temporaries

Comment on lines 2463 to 2475
// Bindings for guards require some extra handling to automatically
// insert implicit references/dereferences.
// This always schedules storage drops, so we may need to unschedule them below.
self.bind_matched_candidate_for_guard(block, sub_branch.bindings.iter());
let guard_frame = GuardFrame {
locals: sub_branch
.bindings
.iter()
.map(|b| GuardFrameLocal::new(b.var_id))
.collect(),
};
debug!("entering guard building context: {:?}", guard_frame);
self.guard_context.push(guard_frame);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to watch out for here: each MatchTreeBranch needs a consistent set of bindings across all sub-branches. I think this means that if any sub-branch has a guard, all sub-branches will need StorageLives for all the RefForGuards.

Human9000-bit and others added 9 commits April 4, 2026 12:48
Co-authored-by: Dianne <diannes.gm@gmail.com>
the problem was in unimplemented exhaustiveness checking, which caused SIGILL
Co-authored-by: dianne <diannes.gm@gmail.com>
`arm_match_scope` isn't provided

Co-authored-by: dianne <diannes.gm@gmail.com>
Co-authored-by: dianne <diannes.gm@gmail.com>
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment on lines 984 to 990
enum PossiblyOr<T> {
/// A single item.
Value(T),
/// Holds the place for an or-pattern's item. This ensures their drops are scheduled in the
/// order the items appear. See rust-lang/rust#142163 for more information.
FromOrPattern,
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the naming ok?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit hard to know what PossiblyOr could mean without looking at the docs; just glancing at it, I read the "or" as the English word, not as a shortened form of "data inlined from a sub-pattern of an or-pattern". I'm not sure I'd recommend this exact name (it's a mouthful!), but something like OrderedPatternData would capture what it's for: it's used for the bits of PatternExtraData that are order-sensitive, in order to preserve their orderings.

I'm also wary about "item" in the comments, since that term has a different technical meaning in Rust. Since this is pretty abstract, it might be worth spelling out the concrete uses and/or putting a doc comment on the enum itself to give a high-level description of it.

Similarly, "value" has a technical meaning in Rust, so I'd caution against using that as the name of the constructor for a single datum.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MaybeOrPat?

@rust-log-analyzer

This comment has been minimized.

Co-authored-by: dianne <diannes.gm@gmail.com>
@rust-log-analyzer

This comment has been minimized.

Co-authored-by: dianne <diannes.gm@gmail.com>
@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
PR_CI_JOB set; skipping tidy
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2026-03-05/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz
---
---- [ui] tests/ui/feature-gates/feature-gate-guard-patterns.rs stdout ----

error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit status: 101
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/feature-gates/feature-gate-guard-patterns.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/feature-gates/feature-gate-guard-patterns" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: unexpected parentheses surrounding `match` arm pattern
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-guard-patterns.rs:12:9
   |
LL |         (0 if guard(0)) => {},
   |         ^             ^
   |
help: remove parentheses surrounding the pattern
   |
LL -         (0 if guard(0)) => {},
LL +         0 if guard(0) => {},
   |

error[E0658]: guard patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-guard-patterns.rs:18:15
   |
LL |         (0 if guard(0)) | 1 => {},
   |               ^^^^^^^^
   |
   = note: see issue #129967 <https://github.com/rust-lang/rust/issues/129967> for more information
   = help: add `#![feature(guard_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
   = help: consider using match arm guards

error[E0658]: guard patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-guard-patterns.rs:23:16
   |
LL |     let ((x if guard(x)) | x) = 0;
   |                ^^^^^^^^
   |
   = note: see issue #129967 <https://github.com/rust-lang/rust/issues/129967> for more information
   = help: add `#![feature(guard_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
   = help: consider using match arm guards

error[E0658]: guard patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-guard-patterns.rs:26:18
   |
LL |     if let (x if guard(x)) = 0 {}
   |                  ^^^^^^^^
   |
   = note: see issue #129967 <https://github.com/rust-lang/rust/issues/129967> for more information
   = help: add `#![feature(guard_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
   = help: consider using match arm guards

error[E0658]: guard patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-guard-patterns.rs:29:21
   |
LL |     while let (x if guard(x)) = 0 {}
   |                     ^^^^^^^^
   |
   = note: see issue #129967 <https://github.com/rust-lang/rust/issues/129967> for more information
   = help: add `#![feature(guard_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
   = help: consider using match arm guards

error[E0658]: guard patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-guard-patterns.rs:33:21
   |
LL |     while let (x if guard(x)) = 0 {}
   |                     ^^^^^^^^
   |
   = note: see issue #129967 <https://github.com/rust-lang/rust/issues/129967> for more information
   = help: add `#![feature(guard_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
   = help: consider using match arm guards

error[E0658]: guard patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-guard-patterns.rs:37:39
   |
LL | fn even_as_function_parameters(((x if guard(x), _) | (_, x)): (i32, i32)) {}
   |                                       ^^^^^^^^
   |
   = note: see issue #129967 <https://github.com/rust-lang/rust/issues/129967> for more information
   = help: add `#![feature(guard_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
   = help: consider using match arm guards

##[error]error: internal compiler error: compiler/rustc_mir_build/src/builder/mod.rs:386:17: anything with one local should never be within a guard.


thread 'rustc' (78746) panicked at compiler/rustc_mir_build/src/builder/mod.rs:386:17:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: <rustc_mir_build::builder::Builder>::var_local_id
---
  18: rustc_mir_build::builder::build_mir_inner_impl
  19: rustc_mir_transform::mir_built
      [... omitted 2 frames ...]
  20: rustc_mir_build::check_unsafety::check_unsafety
      [... omitted 2 frames ...]
  21: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  22: rustc_data_structures::sync::parallel::par_for_each_in::<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}>
  23: <rustc_session::session::Session>::time::<(), rustc_interface::passes::run_required_analyses::{closure#2}>
  24: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  25: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
  26: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
  27: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  28: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
  29: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
  30: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.96.0-nightly (934f29e5f 2026-04-07) running on aarch64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/cargo -Z ignore-directory-in-diagnostics-source-blocks=/checkout/vendor -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -C rpath -C debuginfo=0

query stack during panic:
#0 [mir_built] building MIR for `other_guards_dont`
#1 [check_unsafety] unsafety-checking `other_guards_dont`
#2 [analysis] running analysis passes on crate `feature_gate_guard_patterns`
end of query stack
##[error]error: internal compiler error: compiler/rustc_mir_build/src/builder/mod.rs:386:17: anything with one local should never be within a guard.
   |
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`


thread 'rustc' (78746) panicked at compiler/rustc_mir_build/src/builder/mod.rs:386:17:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: <rustc_mir_build::builder::Builder>::var_local_id
---
  12: rustc_mir_build::builder::build_mir_inner_impl
  13: rustc_mir_transform::mir_built
      [... omitted 2 frames ...]
  14: rustc_mir_build::check_unsafety::check_unsafety
      [... omitted 2 frames ...]
  15: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  16: rustc_data_structures::sync::parallel::par_for_each_in::<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}>
  17: <rustc_session::session::Session>::time::<(), rustc_interface::passes::run_required_analyses::{closure#2}>
  18: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  19: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
  20: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
  21: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  22: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
  23: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
  24: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.96.0-nightly (934f29e5f 2026-04-07) running on aarch64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/cargo -Z ignore-directory-in-diagnostics-source-blocks=/checkout/vendor -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -C rpath -C debuginfo=0

query stack during panic:
#0 [mir_built] building MIR for `even_as_function_parameters`
#1 [check_unsafety] unsafety-checking `even_as_function_parameters`
#2 [analysis] running analysis passes on crate `feature_gate_guard_patterns`
end of query stack
error: aborting due to 9 previous errors

For more information about this error, try `rustc --explain E0658`.
------------------------------------------

---- [ui] tests/ui/feature-gates/feature-gate-guard-patterns.rs stdout end ----
---- [ui] tests/ui/lint/unused/unused_parens/parens-around-guard-patterns-not-unused.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 101
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/lint/unused/unused_parens/parens-around-guard-patterns-not-unused.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/lint/unused/unused_parens/parens-around-guard-patterns-not-unused" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
##[error]error: internal compiler error: compiler/rustc_mir_build/src/builder/scope.rs:514:32: region_scope MatchGuard(6) does not enclose
  --> /checkout/tests/ui/lint/unused/unused_parens/parens-around-guard-patterns-not-unused.rs:12:15
   |
LL |     let (_ if false) = ();
   |               ^^^^^


thread 'rustc' (106763) panicked at compiler/rustc_mir_build/src/builder/scope.rs:514:32:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: <rustc_mir_build::builder::scope::Scopes>::scope_index
   8: <rustc_mir_build::builder::Builder>::break_for_else
   9: <rustc_mir_build::builder::Builder>::then_else_break_inner
  10: <rustc_mir_build::builder::Builder>::then_else_break_inner
  11: <rustc_mir_build::builder::Builder>::then_else_break
  12: <alloc::vec::into_iter::IntoIter<rustc_middle::thir::ExprId> as core::iter::traits::iterator::Iterator>::fold::<rustc_mir_build::builder::BlockAnd<()>, <rustc_mir_build::builder::Builder>::bind_and_guard_matched_candidate::{closure#2}::{closure#0}>
  13: <rustc_mir_build::builder::Builder>::bind_and_guard_matched_candidate
  14: <rustc_mir_build::builder::Builder>::bind_pattern
  15: <rustc_mir_build::builder::Builder>::place_into_pattern
  16: <rustc_mir_build::builder::Builder>::ast_block_stmts
  17: <rustc_mir_build::builder::Builder>::in_scope::<<rustc_mir_build::builder::Builder>::ast_block::{closure#0}, ()>
---
  23: rustc_mir_build::builder::build_mir_inner_impl
  24: rustc_mir_transform::mir_built
      [... omitted 2 frames ...]
  25: rustc_mir_build::check_unsafety::check_unsafety
      [... omitted 2 frames ...]
  26: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  27: rustc_data_structures::sync::parallel::par_for_each_in::<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}>
  28: <rustc_session::session::Session>::time::<(), rustc_interface::passes::run_required_analyses::{closure#2}>
  29: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  30: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
  31: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
  32: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  33: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
  34: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
  35: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.96.0-nightly (934f29e5f 2026-04-07) running on aarch64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/cargo -Z ignore-directory-in-diagnostics-source-blocks=/checkout/vendor -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -C rpath -C debuginfo=0

query stack during panic:
#0 [mir_built] building MIR for `main`
#1 [check_unsafety] unsafety-checking `main`
#2 [analysis] running analysis passes on crate `parens_around_guard_patterns_not_unused`
end of query stack
error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/lint/unused/unused_parens/parens-around-guard-patterns-not-unused.rs stdout end ----
---
To only update this specific test, also pass `--test-args nll/match-guards-partially-borrow.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/nll/match-guards-partially-borrow.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/nll/match-guards-partially-borrow" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0510]: cannot assign `q` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:98:13
   |
LL |     match q {
   |           - value is immutable in match guard
...
LL |             q = true; //~ ERROR
   |             ^^^^^^^^ cannot assign

error[E0510]: cannot assign `q` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:109:13
   |
LL |     match q {
   |           - value is immutable in match guard
...
---
...
LL |             t = true; //~ ERROR
   |             ^^^^^^^^ cannot assign

error[E0510]: cannot mutably borrow `x.0` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:195:22
   |
LL |     match x {
   |           - value is immutable in match guard
...
LL |                 Some(ref mut r) => *r = None, //~ ERROR
   |                      ^^^^^^^^^ cannot mutably borrow

error[E0510]: cannot mutably borrow `x.0` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:211:22
   |
LL |     match x {
   |           - value is immutable in match guard
...
LL |                 Some(ref mut r) => *r = None, //~ ERROR
   |                      ^^^^^^^^^ cannot mutably borrow

error[E0506]: cannot assign to `t` because it is borrowed
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:223:13
   |
LL |         s if {
   |         - `t` is borrowed here
LL |             t = !t; //~ ERROR
   |             ^^^^^^ `t` is assigned to here but it was already borrowed
LL |             false
LL |         } => (), // What value should `s` have in the arm?
   |               - borrow later used here

error[E0506]: cannot assign to `t` because it is borrowed
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:233:13
   |
LL |         s if let Some(()) = {
   |         - `t` is borrowed here
LL |             t = !t; //~ ERROR
   |             ^^^^^^ `t` is assigned to here but it was already borrowed
LL |             None
LL |         } => (), // What value should `s` have in the arm?
   |               - borrow later used here

error[E0510]: cannot assign `y` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:244:13
   |
LL |     match *y {
   |           -- value is immutable in match guard
...
LL |             y = &true; //~ ERROR
   |             ^^^^^^^^^ cannot assign

error[E0510]: cannot assign `y` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:255:13
   |
LL |     match *y {
   |           -- value is immutable in match guard
...
LL |             y = &true; //~ ERROR
   |             ^^^^^^^^^ cannot assign

error[E0510]: cannot assign `z` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:266:13
   |
LL |     match z {
   |           - value is immutable in match guard
...
LL |             z = &true; //~ ERROR
   |             ^^^^^^^^^ cannot assign

error[E0510]: cannot assign `z` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:277:13
   |
LL |     match z {
   |           - value is immutable in match guard
...
LL |             z = &true; //~ ERROR
   |             ^^^^^^^^^ cannot assign

error[E0510]: cannot assign `a` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:289:13
   |
LL |     match a {
   |           - value is immutable in match guard
...
LL |             a = &true; //~ ERROR
   |             ^^^^^^^^^ cannot assign

error[E0510]: cannot assign `a` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:301:13
   |
LL |     match a {
   |           - value is immutable in match guard
...
LL |             a = &true; //~ ERROR
   |             ^^^^^^^^^ cannot assign

error[E0510]: cannot assign `b` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:312:13
   |
LL |     match b {
   |           - value is immutable in match guard
...
LL |             b = &true; //~ ERROR
   |             ^^^^^^^^^ cannot assign

error[E0510]: cannot assign `b` in match guard
##[error]  --> /checkout/tests/ui/nll/match-guards-partially-borrow.rs:323:13
   |
LL |     match b {
   |           - value is immutable in match guard
...
LL |             b = &true; //~ ERROR
   |             ^^^^^^^^^ cannot assign

error: aborting due to 18 previous errors

Some errors have detailed explanations: E0506, E0510.
---
---- [ui] tests/ui/pattern/deref-patterns/fake_borrows.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/pattern/deref-patterns/fake_borrows/fake_borrows.stderr`
diff of stderr:

5    |           - immutable borrow occurs here
6 LL |         deref!([true]) => {}
7 LL |         _ if { v[0] = true; false } => {}
-    |                ^                  - immutable borrow later used here
+    |                ^                        - immutable borrow later used here
9    |                |
10    |                mutable borrow occurs here
11 

16    |           - immutable borrow occurs here
17 LL |         [true] => {}
18 LL |         _ if { v[0] = true; false } => {}
-    |                ^                  - immutable borrow later used here
+    |                ^                        - immutable borrow later used here
20    |                |
21    |                mutable borrow occurs here
22 


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args pattern/deref-patterns/fake_borrows.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/pattern/deref-patterns/fake_borrows.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/pattern/deref-patterns/fake_borrows" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
##[error]  --> /checkout/tests/ui/pattern/deref-patterns/fake_borrows.rs:8:16
   |
LL |     match v {
   |           - immutable borrow occurs here
LL |         deref!([true]) => {}
LL |         _ if { v[0] = true; false } => {}
   |                ^                        - immutable borrow later used here
   |                |
   |                mutable borrow occurs here

error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
##[error]  --> /checkout/tests/ui/pattern/deref-patterns/fake_borrows.rs:15:16
   |
LL |     match v {
   |           - immutable borrow occurs here
LL |         [true] => {}
LL |         _ if { v[0] = true; false } => {}
   |                ^                        - immutable borrow later used here
   |                |
   |                mutable borrow occurs here

error[E0510]: cannot assign `*b` in match guard
##[error]  --> /checkout/tests/ui/pattern/deref-patterns/fake_borrows.rs:25:16
   |
LL |     match b {
   |           - value is immutable in match guard
LL |         deref!(true) => {}
LL |         _ if { *b = true; false } => {}
   |                ^^^^^^^^^ cannot assign

error[E0510]: cannot assign `*b` in match guard
##[error]  --> /checkout/tests/ui/pattern/deref-patterns/fake_borrows.rs:32:16
   |
LL |     match b {
   |           - value is immutable in match guard
LL |         true => {}
LL |         _ if { *b = true; false } => {}
   |                ^^^^^^^^^ cannot assign

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0502, E0510.
---
---- [ui] tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs stdout ----

error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit status: 101
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/pattern/rfc-3637-guard-patterns/name-resolution" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0408]: variable `y` is not bound in all patterns
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:37:10
   |
LL |         ((Ok(x) if y) | (Err(y) if x),) => x && y,
   |          ^^^^^^^^^^^^        - variable not in all patterns
   |          |
   |          pattern doesn't bind `y`
   |
help: you might have meant to use the similarly named previously used binding `x`
   |
LL -         ((Ok(x) if y) | (Err(y) if x),) => x && y,
LL +         ((Ok(x) if y) | (Err(x) if x),) => x && y,
   |

error[E0408]: variable `x` is not bound in all patterns
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:37:25
   |
LL |         ((Ok(x) if y) | (Err(y) if x),) => x && y,
   |              -          ^^^^^^^^^^^^^ pattern doesn't bind `x`
   |              |
   |              variable not in all patterns
   |
help: you might have meant to use the similarly named previously used binding `y`
   |
LL -         ((Ok(x) if y) | (Err(y) if x),) => x && y,
LL +         ((Ok(y) if y) | (Err(y) if x),) => x && y,
   |

error[E0408]: variable `x` is not bound in all patterns
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:63:28
   |
LL |         Some(x if x > 0) | None => {}
   |              -             ^^^^ pattern doesn't bind `x`
   |              |
   |              variable not in all patterns

error[E0425]: cannot find value `x` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:10:34
   |
LL | fn bad_fn_item_1(x: bool, ((y if x) | y): bool) {}
   |                                  ^
   |
help: a local variable with a similar name exists
   |
LL - fn bad_fn_item_1(x: bool, ((y if x) | y): bool) {}
LL + fn bad_fn_item_1(x: bool, ((y if y) | y): bool) {}
   |

error[E0425]: cannot find value `y` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:12:25
   |
LL | fn bad_fn_item_2(((x if y) | x): bool, y: bool) {}
   |                         ^
   |
help: a local variable with a similar name exists
   |
LL - fn bad_fn_item_2(((x if y) | x): bool, y: bool) {}
LL + fn bad_fn_item_2(((x if x) | x): bool, y: bool) {}
   |

error[E0425]: cannot find value `x` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:20:18
   |
LL |         (x, y if x) => x && y,
   |                  ^
   |
help: a local variable with a similar name exists
   |
LL -         (x, y if x) => x && y,
LL +         (x, y if y) => x && y,
   |

error[E0425]: cannot find value `y` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:22:15
   |
LL |         (x if y, y) => x && y,
   |               ^
   |
help: a local variable with a similar name exists
   |
LL -         (x if y, y) => x && y,
LL +         (x if x, y) => x && y,
   |

error[E0425]: cannot find value `x` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:29:20
   |
LL |         (x @ (y if x),) => x && y,
   |                    ^
   |
help: a local variable with a similar name exists
   |
LL -         (x @ (y if x),) => x && y,
LL +         (x @ (y if y),) => x && y,
   |

error[E0425]: cannot find value `y` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:37:20
   |
LL |         ((Ok(x) if y) | (Err(y) if x),) => x && y,
   |                    ^
   |
help: a local variable with a similar name exists
   |
LL -         ((Ok(x) if y) | (Err(y) if x),) => x && y,
LL +         ((Ok(x) if x) | (Err(y) if x),) => x && y,
   |

error[E0425]: cannot find value `x` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:37:36
   |
LL |         ((Ok(x) if y) | (Err(y) if x),) => x && y,
   |                                    ^
   |
help: a local variable with a similar name exists
   |
LL -         ((Ok(x) if y) | (Err(y) if x),) => x && y,
LL +         ((Ok(x) if y) | (Err(y) if y),) => x && y,
   |

error[E0425]: cannot find value `nonexistent` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:44:15
   |
LL |     let (_ if nonexistent) = true;
   |               ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `x` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:46:22
   |
LL |     if let ((x, y if x) | (x if y, y)) = (true, true) { x && y; }
   |                      ^
   |
help: a local variable with a similar name exists
   |
LL -     if let ((x, y if x) | (x if y, y)) = (true, true) { x && y; }
LL +     if let ((x, y if y) | (x if y, y)) = (true, true) { x && y; }
   |

error[E0425]: cannot find value `y` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:46:33
   |
LL |     if let ((x, y if x) | (x if y, y)) = (true, true) { x && y; }
   |                                 ^
   |
help: a local variable with a similar name exists
   |
LL -     if let ((x, y if x) | (x if y, y)) = (true, true) { x && y; }
LL +     if let ((x, y if x) | (x if x, y)) = (true, true) { x && y; }
   |

error[E0425]: cannot find value `x` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:49:25
   |
LL |     while let ((x, y if x) | (x if y, y)) = (true, true) { x && y; }
   |                         ^
   |
help: a local variable with a similar name exists
   |
LL -     while let ((x, y if x) | (x if y, y)) = (true, true) { x && y; }
LL +     while let ((x, y if y) | (x if y, y)) = (true, true) { x && y; }
   |

error[E0425]: cannot find value `y` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:49:36
   |
LL |     while let ((x, y if x) | (x if y, y)) = (true, true) { x && y; }
   |                                    ^
   |
help: a local variable with a similar name exists
   |
LL -     while let ((x, y if x) | (x if y, y)) = (true, true) { x && y; }
LL +     while let ((x, y if x) | (x if x, y)) = (true, true) { x && y; }
   |

error[E0425]: cannot find value `x` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:52:19
   |
LL |     for ((x, y if x) | (x if y, y)) in [(true, true)] { x && y; }
   |                   ^
   |
help: a local variable with a similar name exists
   |
LL -     for ((x, y if x) | (x if y, y)) in [(true, true)] { x && y; }
LL +     for ((x, y if y) | (x if y, y)) in [(true, true)] { x && y; }
   |

error[E0425]: cannot find value `y` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:52:30
   |
LL |     for ((x, y if x) | (x if y, y)) in [(true, true)] { x && y; }
   |                              ^
   |
help: a local variable with a similar name exists
   |
LL -     for ((x, y if x) | (x if y, y)) in [(true, true)] { x && y; }
LL +     for ((x, y if x) | (x if x, y)) in [(true, true)] { x && y; }
   |

error[E0425]: cannot find value `y` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:57:13
   |
LL |     (|(x if y), (y if x)| x && y)(true, true);
   |             ^
   |
help: a local variable with a similar name exists
   |
LL -     (|(x if y), (y if x)| x && y)(true, true);
LL +     (|(x if x), (y if x)| x && y)(true, true);
   |

error[E0425]: cannot find value `x` in this scope
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:57:23
   |
LL |     (|(x if y), (y if x)| x && y)(true, true);
   |                       ^
   |
help: a local variable with a similar name exists
   |
LL -     (|(x if y), (y if x)| x && y)(true, true);
LL +     (|(x if y), (y if y)| x && y)(true, true);
   |

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs:75:18
   |
LL |         local if local => 0,
   |                  ^^^^^ expected `bool`, found `({integer}, {integer})`
   |
   = note: expected type `bool`
             found tuple `({integer}, {integer})`

##[error]error: internal compiler error: compiler/rustc_mir_build/src/builder/mod.rs:386:17: anything with one local should never be within a guard.


thread 'rustc' (131043) panicked at compiler/rustc_mir_build/src/builder/mod.rs:386:17:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: <rustc_mir_build::builder::Builder>::var_local_id
---
  12: rustc_mir_build::builder::build_mir_inner_impl
  13: rustc_mir_transform::mir_built
      [... omitted 2 frames ...]
  14: rustc_mir_build::check_unsafety::check_unsafety
      [... omitted 2 frames ...]
  15: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  16: rustc_data_structures::sync::parallel::par_for_each_in::<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}>
  17: <rustc_session::session::Session>::time::<(), rustc_interface::passes::run_required_analyses::{closure#2}>
  18: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  19: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
  20: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
  21: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  22: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
  23: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
  24: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.96.0-nightly (934f29e5f 2026-04-07) running on aarch64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/cargo -Z ignore-directory-in-diagnostics-source-blocks=/checkout/vendor -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -C rpath -C debuginfo=0

query stack during panic:
#0 [mir_built] building MIR for `good_fn_item`
#1 [check_unsafety] unsafety-checking `good_fn_item`
#2 [analysis] running analysis passes on crate `name_resolution`
end of query stack
error: aborting due to 21 previous errors

Some errors have detailed explanations: E0308, E0408, E0425.
For more information about an error, try `rustc --explain E0308`.
------------------------------------------

---- [ui] tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.rs stdout end ----
---- [ui] tests/ui/reachable/guard_read_for_never.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 101
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/reachable/guard_read_for_never.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/reachable/guard_read_for_never" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
##[error]error: internal compiler error: compiler/rustc_mir_build/src/builder/scope.rs:514:32: region_scope MatchGuard(20) does not enclose
  --> /checkout/tests/ui/reachable/guard_read_for_never.rs:13:19
   |
LL |         let (_ if false): ! = *x;
   |                   ^^^^^


thread 'rustc' (139567) panicked at compiler/rustc_mir_build/src/builder/scope.rs:514:32:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: <rustc_mir_build::builder::scope::Scopes>::scope_index
   8: <rustc_mir_build::builder::Builder>::break_for_else
   9: <rustc_mir_build::builder::Builder>::then_else_break_inner
  10: <rustc_mir_build::builder::Builder>::then_else_break_inner
  11: <rustc_mir_build::builder::Builder>::then_else_break
  12: <alloc::vec::into_iter::IntoIter<rustc_middle::thir::ExprId> as core::iter::traits::iterator::Iterator>::fold::<rustc_mir_build::builder::BlockAnd<()>, <rustc_mir_build::builder::Builder>::bind_and_guard_matched_candidate::{closure#2}::{closure#0}>
  13: <rustc_mir_build::builder::Builder>::bind_and_guard_matched_candidate
  14: <rustc_mir_build::builder::Builder>::bind_pattern
  15: <rustc_mir_build::builder::Builder>::place_into_pattern
  16: <rustc_mir_build::builder::Builder>::ast_block_stmts
  17: <rustc_mir_build::builder::Builder>::in_scope::<<rustc_mir_build::builder::Builder>::ast_block::{closure#0}, ()>
---
  29: rustc_mir_build::builder::build_mir_inner_impl
  30: rustc_mir_transform::mir_built
      [... omitted 2 frames ...]
  31: rustc_mir_build::check_unsafety::check_unsafety
      [... omitted 2 frames ...]
  32: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  33: rustc_data_structures::sync::parallel::par_for_each_in::<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}>
  34: <rustc_session::session::Session>::time::<(), rustc_interface::passes::run_required_analyses::{closure#2}>
  35: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  36: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
  37: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
  38: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  39: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
  40: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
  41: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.96.0-nightly (934f29e5f 2026-04-07) running on aarch64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/cargo -Z ignore-directory-in-diagnostics-source-blocks=/checkout/vendor -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -C rpath -C debuginfo=0

query stack during panic:
#0 [mir_built] building MIR for `main`
#1 [check_unsafety] unsafety-checking `main`
#2 [analysis] running analysis passes on crate `guard_read_for_never`
end of query stack
error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/reachable/guard_read_for_never.rs stdout end ----
---- [ui] tests/ui/thir-print/str-patterns.rs stdout ----
Saved the actual stdout to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/thir-print/str-patterns/str-patterns.stdout`
diff of stdout:

48                             DefId(0:4 ~ str_patterns[fc71]::CONSTANT),
49                         ),
50                         ascriptions: [],
+                         scope: None,
51                     },
52                 ),
---
To only update this specific test, also pass `--test-args thir-print/str-patterns.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/thir-print/str-patterns.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/thir-print/str-patterns" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2024" "-Zunpretty=thir-flat"
--- stdout -------------------------------
DefId(0:3 ~ str_patterns[fc71]::hello_world):
Thir {
    body_type: Fn(
        fn(&'{erased} str),
    ),
    arms: [
        Arm {
            pattern: Pat {
                ty: &'{erased} str,
                span: /checkout/tests/ui/thir-print/str-patterns.rs:11:9: 11:16 (#0),
                extra: None,
                kind: Deref {
                    pin: Not,
                    subpattern: Pat {
                        ty: str,
                        span: /checkout/tests/ui/thir-print/str-patterns.rs:11:9: 11:16 (#0),
                        extra: None,
---
                        },
                    },
                },
            },
            guard: None,
            body: e3,
            hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).9),
            scope: Node(9),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:11:9: 11:22 (#0),
        },
        Arm {
            pattern: Pat {
                ty: &'{erased} str,
                span: /checkout/tests/ui/thir-print/str-patterns.rs:12:9: 12:17 (#0),
                extra: Some(
                    PatExtra {
                        expanded_const: Some(
                            DefId(0:4 ~ str_patterns[fc71]::CONSTANT),
                        ),
                        ascriptions: [],
                        scope: None,
                    },
                ),
---
                        },
                    },
                },
            },
            guard: None,
            body: e5,
            hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).15),
            scope: Node(15),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:12:9: 12:23 (#0),
        },
        Arm {
            pattern: Pat {
                ty: &'{erased} str,
                span: /checkout/tests/ui/thir-print/str-patterns.rs:13:9: 13:10 (#0),
                extra: None,
                kind: Wild,
            },
            guard: None,
            body: e7,
            hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).19),
            scope: Node(19),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:13:9: 13:16 (#0),
        },
    ],
    blocks: [
        Block {
            targeted_by_break: false,
            region_scope: Node(11),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:11:20: 11:22 (#0),
            stmts: [],
            expr: None,
            safety_mode: Safe,
        },
        Block {
            targeted_by_break: false,
            region_scope: Node(17),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:12:21: 12:23 (#0),
            stmts: [],
            expr: None,
            safety_mode: Safe,
        },
        Block {
            targeted_by_break: false,
            region_scope: Node(21),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:13:14: 13:16 (#0),
            stmts: [],
            expr: None,
            safety_mode: Safe,
        },
        Block {
            targeted_by_break: false,
            region_scope: Node(3),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:9:29: 15:2 (#0),
            stmts: [],
            expr: Some(
                e9,
            ),
            safety_mode: Safe,
        },
    ],
    exprs: [
        Expr {
            kind: VarRef {
                id: LocalVarId(
                    HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).2),
                ),
            },
            ty: &'{erased} str,
            temp_scope_id: 5,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:10:11: 10:12 (#0),
        },
        Expr {
            kind: Scope {
                region_scope: Node(5),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).5),
                value: e0,
            },
            ty: &'{erased} str,
            temp_scope_id: 5,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:10:11: 10:12 (#0),
        },
        Expr {
            kind: Block {
                block: b0,
            },
            ty: (),
            temp_scope_id: 10,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:11:20: 11:22 (#0),
        },
        Expr {
            kind: Scope {
                region_scope: Node(10),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).10),
                value: e2,
            },
            ty: (),
            temp_scope_id: 10,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:11:20: 11:22 (#0),
        },
---
        },
        Expr {
            kind: Scope {
                region_scope: Node(16),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).16),
                value: e4,
            },
            ty: (),
            temp_scope_id: 16,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:12:21: 12:23 (#0),
        },
---
        },
        Expr {
            kind: Scope {
                region_scope: Node(20),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).20),
                value: e6,
            },
            ty: (),
            temp_scope_id: 20,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:13:14: 13:16 (#0),
        },
---
        },
        Expr {
            kind: Scope {
                region_scope: Node(4),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).4),
                value: e8,
            },
            ty: (),
            temp_scope_id: 4,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:10:5: 14:6 (#0),
        },
---
        },
        Expr {
            kind: Scope {
                region_scope: Node(22),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).22),
                value: e10,
            },
            ty: (),
            temp_scope_id: 22,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:9:29: 15:2 (#0),
        },
    ],
    stmts: [],
    params: [
        Param {
            pat: Some(
                Pat {
                    ty: &'{erased} str,
                    span: /checkout/tests/ui/thir-print/str-patterns.rs:9:20: 9:21 (#0),
                    extra: None,
                    kind: Binding {
                        name: "x",
                        mode: BindingMode(
                            No,
                            Not,
                        ),
                        var: LocalVarId(
                            HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).2),
                        ),
                        ty: &'{erased} str,
                        subpattern: None,
                        is_primary: true,
                        is_shorthand: false,
                    },
                },
            ),
            ty: &'{erased} str,
            ty_span: Some(
                /checkout/tests/ui/thir-print/str-patterns.rs:9:23: 9:27 (#0),
            ),
            self_kind: None,
            hir_id: Some(
                HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).1),
            ),
        },
    ],
}

DefId(0:4 ~ str_patterns[fc71]::CONSTANT):
Thir {
    body_type: Const(
        &'{erased} str,
    ),
    arms: [],
    blocks: [],
    exprs: [
        Expr {
---
                    span: /checkout/tests/ui/thir-print/str-patterns.rs:17:24: 17:34 (#0),
                },
                neg: false,
            },
            ty: &'{erased} str,
            temp_scope_id: 5,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:17:24: 17:34 (#0),
        },
        Expr {
            kind: Scope {
                region_scope: Node(5),
                hir_id: HirId(DefId(0:4 ~ str_patterns[fc71]::CONSTANT).5),
                value: e0,
            },
            ty: &'{erased} str,
            temp_scope_id: 5,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:17:24: 17:34 (#0),
        },
    ],
    stmts: [],
    params: [],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

8 participants