Issue #5967: Make rvalues mutable
This commit is contained in:
parent
5a2f65fb50
commit
d204cfd739
2 changed files with 10 additions and 2 deletions
|
|
@ -93,7 +93,7 @@ impl GuaranteeLifetimeContext {
|
|||
let omit_root = (
|
||||
ptr_mutbl == m_imm &&
|
||||
self.bccx.is_subregion_of(self.loan_region, base_scope) &&
|
||||
base.mutbl.is_immutable() &&
|
||||
self.is_rvalue_or_immutable(base) &&
|
||||
!self.is_moved(base)
|
||||
);
|
||||
|
||||
|
|
@ -168,6 +168,14 @@ impl GuaranteeLifetimeContext {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_rvalue_or_immutable(&self,
|
||||
cmt: mc::cmt) -> bool {
|
||||
cmt.mutbl.is_immutable() || match cmt.guarantor().cat {
|
||||
mc::cat_rvalue => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn check_root(&self,
|
||||
cmt_deref: mc::cmt,
|
||||
cmt_base: mc::cmt,
|
||||
|
|
|
|||
|
|
@ -551,7 +551,7 @@ pub impl mem_categorization_ctxt {
|
|||
id:elt.id(),
|
||||
span:elt.span(),
|
||||
cat:cat_rvalue,
|
||||
mutbl:McImmutable,
|
||||
mutbl:McDeclared,
|
||||
ty:expr_ty
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue