borrowck: fix critical bug prevent us from ever using write guards :)
This commit is contained in:
parent
418f991118
commit
dc21daeeb8
@ -357,6 +357,8 @@ pub impl<'self> CheckLoanCtxt<'self> {
|
||||
//! Safety checks related to writes to aliasable, mutable locations
|
||||
|
||||
let guarantor = cmt.guarantor();
|
||||
debug!("check_for_aliasable_mutable_writes(cmt=%s, guarantor=%s)",
|
||||
cmt.repr(self.tcx()), guarantor.repr(self.tcx()));
|
||||
match guarantor.cat {
|
||||
mc::cat_deref(b, _, mc::region_ptr(m_mutbl, _)) => {
|
||||
// Statically prohibit writes to `&mut` when aliasable
|
||||
@ -379,6 +381,7 @@ pub impl<'self> CheckLoanCtxt<'self> {
|
||||
id: base.id,
|
||||
derefs: deref_count
|
||||
};
|
||||
debug!("Inserting write guard at %?", key);
|
||||
self.bccx.write_guard_map.insert(key);
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ impl GuaranteeLifetimeContext {
|
||||
|
||||
// See rule Freeze-Imm-Managed-Ptr-2 in doc.rs
|
||||
let omit_root = (
|
||||
ptr_mutbl == m_imm &&
|
||||
self.bccx.is_subregion_of(self.loan_region, base_scope) &&
|
||||
base.mutbl.is_immutable() &&
|
||||
!self.is_moved(base)
|
||||
|
@ -148,7 +148,7 @@ fn gather_loans_in_expr(ex: @ast::expr,
|
||||
|
||||
// If this expression is borrowed, have to ensure it remains valid:
|
||||
{
|
||||
let mut this = &mut *self; // FIXME(#5074)
|
||||
let this = &mut *self; // FIXME(#5074)
|
||||
if !this.ignore_adjustments.contains(&ex.id) {
|
||||
for tcx.adjustments.find(&ex.id).each |&adjustments| {
|
||||
this.guarantee_adjustments(ex, *adjustments);
|
||||
@ -283,7 +283,7 @@ pub impl GatherLoanCtxt {
|
||||
let mcx = &mc::mem_categorization_ctxt {
|
||||
tcx: self.tcx(),
|
||||
method_map: self.bccx.method_map};
|
||||
let mut cmt = mcx.cat_expr_autoderefd(expr, autoderefs);
|
||||
let cmt = mcx.cat_expr_autoderefd(expr, autoderefs);
|
||||
debug!("after autoderef, cmt=%s", cmt.repr(self.tcx()));
|
||||
|
||||
match *autoref {
|
||||
|
@ -1,22 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-win32
|
||||
// error-pattern:ran out of stack
|
||||
|
||||
// Test that the task fails after hitting the recursion limit, but
|
||||
// that it doesn't bring down the whole proc
|
||||
|
||||
pub fn main() {
|
||||
do task::spawn_unlinked {
|
||||
fn f() { f() };
|
||||
f();
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user