Ensure inherited reference is never set to &mut
behind an &
This commit is contained in:
parent
b6c409723b
commit
e3945bd3a8
6 changed files with 124 additions and 67 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue