Skip to content

Commit 84ed100

Browse files
Address review comments
1 parent b29039e commit 84ed100

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compiler/rustc_ast/src/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,8 @@ impl BindingAnnotation {
734734
}
735735

736736
pub fn cap_ref_mutability(mut self, mutbl: Mutability) -> Self {
737-
if let ByRef::Yes(old_mutbl) = self.0 {
738-
self.0 = ByRef::Yes(cmp::min(old_mutbl, mutbl));
737+
if let ByRef::Yes(old_mutbl) = &mut self.0 {
738+
*old_mutbl = cmp::min(*old_mutbl, mutbl);
739739
}
740740
self
741741
}

compiler/rustc_hir_typeck/src/pat.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
447447
// This is because a `& &mut` cannot mutate the underlying value.
448448
ByRef::Yes(Mutability::Not) => Mutability::Not,
449449
});
450+
}
450451

451-
if pat.span.at_least_rust_2024() && self.tcx.features().ref_pat_eat_one_layer_2024 {
452-
max_ref_mutability = cmp::min(max_ref_mutability, inner_mutability);
453-
def_bm = def_bm.cap_ref_mutability(max_ref_mutability);
452+
if pat.span.at_least_rust_2024() && self.tcx.features().ref_pat_eat_one_layer_2024 {
453+
def_bm = def_bm.cap_ref_mutability(max_ref_mutability);
454+
if def_bm.0 == ByRef::Yes(Mutability::Not) {
455+
max_ref_mutability = Mutability::Not;
454456
}
455457
}
456458

0 commit comments

Comments
 (0)