Ensure inherited reference is never set to &mut behind an &
This commit is contained in:
@@ -36,6 +36,7 @@ use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::source_map::{respan, Spanned};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
|
||||
use std::cmp;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use thin_vec::{thin_vec, ThinVec};
|
||||
@@ -731,6 +732,13 @@ 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) = self.0 {
|
||||
self.0 = ByRef::Yes(cmp::min(old_mutbl, mutbl));
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user