From ff165d54cbfc4734ae889e861ef9fd94ecfc5375 Mon Sep 17 00:00:00 2001 From: dianne Date: Tue, 31 Dec 2024 17:59:36 -0800 Subject: pattern typing cleanup: remove a redundant assignment As far as I can tell, the assignment removed here will never do anything. `pat_info.max_ref_mutbl` starts at `MutblCap::Mut` for the top-level pattern and is only changed if feature gates are enabled that would result in the statement not being executed. Regardless of what new pattern typing rules are adopted, I don't imagine we want to conditionally reset `max_ref_mutbl` based on edition either, since it'd have consequences for subpatterns in other editions. --- compiler/rustc_hir_typeck/src/pat.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 4870e6193c3..5e6cca51c92 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -2216,13 +2216,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let pat_prefix_span = inner.span.find_ancestor_inside(pat.span).map(|end| pat.span.until(end)); - if no_ref_mut_behind_and { - 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(pat_prefix_span); - } - } else { - pat_info.max_ref_mutbl = MutblCap::Mut; + if no_ref_mut_behind_and && 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(pat_prefix_span); } expected = self.try_structurally_resolve_type(pat.span, expected); -- cgit 1.4.1-3-g733a5