提交 dc21daee 编写于 作者: N Niko Matsakis

borrowck: fix critical bug prevent us from ever using write guards :)

上级 418f9911
......@@ -357,6 +357,8 @@ fn check_for_aliasable_mutable_writes(self: &CheckLoanCtxt,
//! 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 @@ fn check_for_aliasable_mutable_writes(self: &CheckLoanCtxt,
id: base.id,
derefs: deref_count
};
debug!("Inserting write guard at %?", key);
self.bccx.write_guard_map.insert(key);
}
......
......@@ -90,6 +90,7 @@ fn check(&self, cmt: mc::cmt, discr_scope: Option<ast::node_id>) {
// 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 @@ fn guarantee_adjustments(&mut self,
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 {
......
// 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();
};
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册