1
Fork 0

Store ByRef instead of BindingAnnotation in PatInfo

This commit is contained in:
Jules Bertholet 2024-04-16 19:05:17 -04:00
parent 6c6b3027ef
commit d19e48d79a
No known key found for this signature in database
GPG key ID: 32034DAFC38C1BFC
2 changed files with 30 additions and 30 deletions

View file

@ -707,6 +707,15 @@ pub enum ByRef {
No,
}
impl ByRef {
pub fn cap_ref_mutability(mut self, mutbl: Mutability) -> Self {
if let ByRef::Yes(old_mutbl) = &mut self {
*old_mutbl = cmp::min(*old_mutbl, mutbl);
}
self
}
}
/// Explicit binding annotations given in the HIR for a binding. Note
/// that this is not the final binding *mode* that we infer after type
/// inference.
@ -732,13 +741,6 @@ impl BindingAnnotation {
Self::MUT_REF_MUT => "mut ref mut ",
}
}
pub fn cap_ref_mutability(mut self, mutbl: Mutability) -> Self {
if let ByRef::Yes(old_mutbl) = &mut self.0 {
*old_mutbl = cmp::min(*old_mutbl, mutbl);
}
self
}
}
#[derive(Clone, Encodable, Decodable, Debug)]