about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2013-04-30 16:34:22 -0400
committerNiko Matsakis <niko@alum.mit.edu>2013-04-30 16:34:22 -0400
commitdc21daeeb88c20b6431e70fe4ef5cc416af8410d (patch)
tree4ef3a3dc23df54f38ca2c3ec4fcef87713fada3e
parent418f99111852d13e9446c70cd616e6e6780bb632 (diff)
downloadrust-dc21daeeb88c20b6431e70fe4ef5cc416af8410d.tar.gz
rust-dc21daeeb88c20b6431e70fe4ef5cc416af8410d.zip
borrowck: fix critical bug prevent us from ever using write guards :)
-rw-r--r--src/librustc/middle/borrowck/check_loans.rs3
-rw-r--r--src/librustc/middle/borrowck/gather_loans/lifetime.rs1
-rw-r--r--src/librustc/middle/borrowck/gather_loans/mod.rs4
-rw-r--r--src/test/run-pass/too-much-recursion.rs22
4 files changed, 6 insertions, 24 deletions
diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs
index 9330395c061..70da9c93805 100644
--- a/src/librustc/middle/borrowck/check_loans.rs
+++ b/src/librustc/middle/borrowck/check_loans.rs
@@ -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);
                 }
 
diff --git a/src/librustc/middle/borrowck/gather_loans/lifetime.rs b/src/librustc/middle/borrowck/gather_loans/lifetime.rs
index 4d267b7dc47..fdfb26c0d08 100644
--- a/src/librustc/middle/borrowck/gather_loans/lifetime.rs
+++ b/src/librustc/middle/borrowck/gather_loans/lifetime.rs
@@ -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)
diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs
index 1bc3b70ac38..8a986a22d4c 100644
--- a/src/librustc/middle/borrowck/gather_loans/mod.rs
+++ b/src/librustc/middle/borrowck/gather_loans/mod.rs
@@ -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 {
diff --git a/src/test/run-pass/too-much-recursion.rs b/src/test/run-pass/too-much-recursion.rs
deleted file mode 100644
index adccc786926..00000000000
--- a/src/test/run-pass/too-much-recursion.rs
+++ /dev/null
@@ -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();
-    };
-}