diff options
| author | dianne <diannes.gm@gmail.com> | 2025-08-07 16:17:54 -0700 |
|---|---|---|
| committer | dianne <diannes.gm@gmail.com> | 2025-08-07 16:51:41 -0700 |
| commit | 0bdaef5b63fe2d557483e72732e463b86ffb041b (patch) | |
| tree | 246fb86db28d2fa97f4ca11da65979f13b157ed4 /compiler/rustc_hir_analysis/src | |
| parent | b2241c78c86a15b8e7e842f036135df4478de0fe (diff) | |
only introduce a guard scope for arms with guards
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/region.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/region.rs b/compiler/rustc_hir_analysis/src/check/region.rs index d43ac053758..f5770b7312d 100644 --- a/compiler/rustc_hir_analysis/src/check/region.rs +++ b/compiler/rustc_hir_analysis/src/check/region.rs @@ -198,12 +198,12 @@ fn resolve_arm<'tcx>(visitor: &mut ScopeResolutionVisitor<'tcx>, arm: &'tcx hir: visitor.cx.var_parent = visitor.cx.parent; resolve_pat(visitor, arm.pat); - // We introduce a new scope to contain bindings and temporaries from `if let` guards, to - // ensure they're dropped before the arm's pattern's bindings. This extends to the end of - // the arm body and is the scope of its locals as well. - visitor.enter_scope(Scope { local_id: arm.hir_id.local_id, data: ScopeData::MatchGuard }); - visitor.cx.var_parent = visitor.cx.parent; if let Some(guard) = arm.guard { + // We introduce a new scope to contain bindings and temporaries from `if let` guards, to + // ensure they're dropped before the arm's pattern's bindings. This extends to the end of + // the arm body and is the scope of its locals as well. + visitor.enter_scope(Scope { local_id: arm.hir_id.local_id, data: ScopeData::MatchGuard }); + visitor.cx.var_parent = visitor.cx.parent; resolve_cond(visitor, guard); } resolve_expr(visitor, arm.body, false); |
