Address review comments

This commit is contained in:
Jules Bertholet 2024-04-14 10:52:37 -04:00
parent e3945bd3a8
commit 88cd821e62
No known key found for this signature in database
GPG key ID: 32034DAFC38C1BFC
2 changed files with 7 additions and 5 deletions

View file

@ -734,8 +734,8 @@ impl BindingAnnotation {
}
pub fn cap_ref_mutability(mut self, mutbl: Mutability) -> Self {
if let ByRef::Yes(old_mutbl) = self.0 {
self.0 = ByRef::Yes(cmp::min(old_mutbl, mutbl));
if let ByRef::Yes(old_mutbl) = &mut self.0 {
*old_mutbl = cmp::min(*old_mutbl, mutbl);
}
self
}

View file

@ -447,10 +447,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// This is because a `& &mut` cannot mutate the underlying value.
ByRef::Yes(Mutability::Not) => Mutability::Not,
});
}
if pat.span.at_least_rust_2024() && self.tcx.features().ref_pat_eat_one_layer_2024 {
max_ref_mutability = cmp::min(max_ref_mutability, inner_mutability);
def_bm = def_bm.cap_ref_mutability(max_ref_mutability);
if pat.span.at_least_rust_2024() && self.tcx.features().ref_pat_eat_one_layer_2024 {
def_bm = def_bm.cap_ref_mutability(max_ref_mutability);
if def_bm.0 == ByRef::Yes(Mutability::Not) {
max_ref_mutability = Mutability::Not;
}
}