]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Remove root_map usage from lifetime
authorFlavio Percoco <flaper87@gmail.com>
Tue, 15 Apr 2014 21:33:37 +0000 (23:33 +0200)
committerFlavio Percoco <flaper87@gmail.com>
Wed, 23 Apr 2014 16:19:30 +0000 (18:19 +0200)
src/librustc/middle/borrowck/gather_loans/lifetime.rs
src/test/compile-fail/regions-infer-borrow-scope-too-big.rs [deleted file]
src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs [deleted file]

index a27fe5cec225260b32d44ec880199c97c330e4d2..a582964bb7c50c270f226ab46140eb41543568bf 100644 (file)
@@ -90,7 +90,7 @@ fn check(&self, cmt: &mc::cmt, discr_scope: Option<ast::NodeId>) -> R {
                 Ok(())
             }
 
-            mc::cat_deref(ref base, derefs, mc::GcPtr) => {
+            mc::cat_deref(ref base, _, mc::GcPtr) => {
                 let base_scope = self.scope(base);
 
                 // L-Deref-Managed-Imm-User-Root
@@ -102,7 +102,7 @@ fn check(&self, cmt: &mc::cmt, discr_scope: Option<ast::NodeId>) -> R {
                 if !omit_root {
                     // L-Deref-Managed-Imm-Compiler-Root
                     // L-Deref-Managed-Mut-Compiler-Root
-                    self.check_root(cmt, base, derefs, discr_scope)
+                    Err(())
                 } else {
                     debug!("omitting root, base={}, base_scope={:?}",
                            base.repr(self.tcx()), base_scope);
@@ -187,61 +187,6 @@ fn is_rvalue_or_immutable(&self,
         }
     }
 
-    fn check_root(&self,
-                  cmt_deref: &mc::cmt,
-                  cmt_base: &mc::cmt,
-                  derefs: uint,
-                  discr_scope: Option<ast::NodeId>) -> R {
-        debug!("check_root(cmt_deref={}, cmt_base={}, derefs={:?}, \
-                discr_scope={:?})",
-               cmt_deref.repr(self.tcx()),
-               cmt_base.repr(self.tcx()),
-               derefs,
-               discr_scope);
-
-        // Make sure that the loan does not exceed the maximum time
-        // that we can root the value, dynamically.
-        let root_region = ty::ReScope(self.root_scope_id);
-        if !self.bccx.is_subregion_of(self.loan_region, root_region) {
-            return Err(self.report_error(
-                err_out_of_root_scope(root_region, self.loan_region)));
-        }
-
-        // Extract the scope id that indicates how long the rooting is required
-        let root_scope = match self.loan_region {
-            ty::ReScope(id) => id,
-            _ => {
-                // the check above should fail for anything is not ReScope
-                self.bccx.tcx.sess.span_bug(
-                    cmt_base.span,
-                    format!("cannot issue root for scope region: {:?}",
-                         self.loan_region));
-            }
-        };
-
-        // If inside of a match arm, expand the rooting to the entire
-        // match. See the detailed discussion in `check()` above.
-        let root_scope = match discr_scope {
-            None => root_scope,
-            Some(id) => {
-                if self.bccx.is_subscope_of(root_scope, id) {
-                    id
-                } else {
-                    root_scope
-                }
-            }
-        };
-
-        // Add a record of what is required
-        let rm_key = root_map_key {id: cmt_deref.id, derefs: derefs};
-        let root_info = RootInfo {scope: root_scope};
-
-        self.bccx.root_map.borrow_mut().insert(rm_key, root_info);
-
-        debug!("root_key: {:?} root_info: {:?}", rm_key, root_info);
-        Ok(())
-    }
-
     fn check_scope(&self, max_scope: ty::Region) -> R {
         //! Reports an error if `loan_region` is larger than `valid_scope`
 
diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs
deleted file mode 100644 (file)
index b069a35..0000000
+++ /dev/null
@@ -1,28 +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.
-
-#![feature(managed_boxes)]
-
-struct point {
-    x: int,
-    y: int,
-}
-
-fn x_coord<'r>(p: &'r point) -> &'r int {
-    return &p.x;
-}
-
-fn foo(p: @point) -> &int {
-    let xc = x_coord(p); //~ ERROR cannot root
-    assert_eq!(*xc, 3);
-    return xc;
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
deleted file mode 100644 (file)
index 9be8a5f..0000000
+++ /dev/null
@@ -1,30 +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.
-
-#![feature(managed_boxes)]
-
-fn borrow<'r, T>(x: &'r T) -> &'r T {x}
-
-fn foo(cond: || -> bool, make_box: || -> @int) {
-    let mut y: &int;
-    loop {
-        let x = make_box();
-
-        // Here we complain because the resulting region
-        // of this borrow is the fn body as a whole.
-        y = borrow(x); //~ ERROR cannot root
-
-        assert_eq!(*x, *y);
-        if cond() { break; }
-    }
-    assert!(*y != 0);
-}
-
-fn main() {}