From 6d5c6f541f5dc9f3142c84bbc5203e57c0a4a18c Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Fri, 10 May 2024 13:53:48 -0400 Subject: [PATCH] Add comment on `cap_to_weakly_not` Co-authored-by: Guillaume Boisseau --- compiler/rustc_hir_typeck/src/pat.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index b18da758c1c..7029f5433d8 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -2141,6 +2141,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut inherited_ref_mutbl_match = false; if match_ergonomics_mode != MatchErgonomicsMode::Legacy { if pat_mutbl == Mutability::Not { + // Prevent the inner pattern from binding with `ref mut`. pat_info.max_ref_mutbl = pat_info.max_ref_mutbl.cap_to_weakly_not( inner.span.find_ancestor_inside(pat.span).map(|end| pat.span.until(end)), );