Skip to content

Commit

Permalink
Issue rust-lang#5967: Make rvalues mutable
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed May 14, 2013
1 parent 5a2f65f commit d204cfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/librustc/middle/borrowck/gather_loans/lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit d204cfd

Please sign in to comment.