librustc: Disallow &mut loans from overlapping with any other loans

This commit is contained in:
Patrick Walton 2013-01-17 16:15:08 -08:00
parent 163b97b7bb
commit bbbb80559c
4 changed files with 15 additions and 10 deletions

View file

@ -296,12 +296,11 @@ impl check_loan_ctxt {
}
match (old_loan.mutbl, new_loan.mutbl) {
(m_const, _) | (_, m_const) |
(m_mutbl, m_mutbl) | (m_imm, m_imm) => {
(m_const, _) | (_, m_const) | (m_imm, m_imm) => {
/*ok*/
}
(m_mutbl, m_imm) | (m_imm, m_mutbl) => {
(m_mutbl, m_mutbl) | (m_mutbl, m_imm) | (m_imm, m_mutbl) => {
self.bccx.span_err(
new_loan.cmt.span,
fmt!("loan of %s as %s \
@ -418,8 +417,8 @@ impl check_loan_ctxt {
for self.walk_loans_of(ex.id, lp) |loan| {
match loan.mutbl {
m_mutbl | m_const => { /*ok*/ }
m_imm => {
m_const => { /*ok*/ }
m_mutbl | m_imm => {
self.bccx.span_err(
ex.span,
fmt!("%s prohibited due to outstanding loan",

View file

@ -251,7 +251,7 @@ impl LoanContext {
// Variant components: the base must be immutable, because
// if it is overwritten, the types of the embedded data
// could change.
do self.loan(cmt_base, m_imm).chain |_ok| {
do self.loan(cmt_base, m_imm).chain |_| {
// can use static, as in loan_stable_comp()
self.issue_loan(cmt, ty::re_static, req_mutbl)
}