Skip to content

Commit ff165d5

Browse files
committed
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.
1 parent 550b0ad commit ff165d5

File tree

1 file changed

+3
-7
lines changed
  • compiler/rustc_hir_typeck/src

1 file changed

+3
-7
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -2216,13 +2216,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22162216
let pat_prefix_span =
22172217
inner.span.find_ancestor_inside(pat.span).map(|end| pat.span.until(end));
22182218

2219-
if no_ref_mut_behind_and {
2220-
if pat_mutbl == Mutability::Not {
2221-
// Prevent the inner pattern from binding with `ref mut`.
2222-
pat_info.max_ref_mutbl = pat_info.max_ref_mutbl.cap_to_weakly_not(pat_prefix_span);
2223-
}
2224-
} else {
2225-
pat_info.max_ref_mutbl = MutblCap::Mut;
2219+
if no_ref_mut_behind_and && pat_mutbl == Mutability::Not {
2220+
// Prevent the inner pattern from binding with `ref mut`.
2221+
pat_info.max_ref_mutbl = pat_info.max_ref_mutbl.cap_to_weakly_not(pat_prefix_span);
22262222
}
22272223

22282224
expected = self.try_structurally_resolve_type(pat.span, expected);

0 commit comments

Comments
 (0)