about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2014-04-15 22:05:37 +0200
committerFlavio Percoco <flaper87@gmail.com>2014-04-23 18:19:05 +0200
commit71f054ddd02051928e8e60356ecd95cb0b3f64e6 (patch)
tree38bb4ef7c9c6c3194f17d432523a8d1766e6b2db
parent30fe55066a29a14fffd2a5f41e0ab21e7056fb34 (diff)
downloadrust-71f054ddd02051928e8e60356ecd95cb0b3f64e6.tar.gz
rust-71f054ddd02051928e8e60356ecd95cb0b3f64e6.zip
Remove special rooting code from trans
[breaking-change]

cc #11586
-rw-r--r--src/librustc/middle/trans/expr.rs3
-rw-r--r--src/librustc/middle/trans/mod.rs1
-rw-r--r--src/librustc/middle/trans/write_guard.rs63
-rw-r--r--src/test/run-pass/borrowck-preserve-box-in-field.rs37
-rw-r--r--src/test/run-pass/borrowck-preserve-box-in-uniq.rs37
-rw-r--r--src/test/run-pass/borrowck-preserve-box.rs35
-rw-r--r--src/test/run-pass/borrowck-preserve-cond-box.rs45
-rw-r--r--src/test/run-pass/borrowck-preserve-expl-deref.rs37
8 files changed, 0 insertions, 258 deletions
diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs
index 3c1dfedcac6..9bb0375bf44 100644
--- a/src/librustc/middle/trans/expr.rs
+++ b/src/librustc/middle/trans/expr.rs
@@ -59,7 +59,6 @@ use middle::trans::meth;
 use middle::trans::inline;
 use middle::trans::tvec;
 use middle::trans::type_of;
-use middle::trans::write_guard;
 use middle::ty::struct_fields;
 use middle::ty::{AutoBorrowObj, AutoDerefRef, AutoAddEnv, AutoObject, AutoUnsafe};
 use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef};
@@ -1676,8 +1675,6 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
                   derefs: uint)
                   -> DatumBlock<'a, Expr> {
     let ccx = bcx.ccx();
-    let bcx = write_guard::root_and_write_guard(&datum, bcx, expr.span,
-                                                expr.id, derefs);
 
     debug!("deref_once(expr={}, datum={}, derefs={})",
            expr.repr(bcx.tcx()),
diff --git a/src/librustc/middle/trans/mod.rs b/src/librustc/middle/trans/mod.rs
index 7ac491edfeb..f07adb1ed87 100644
--- a/src/librustc/middle/trans/mod.rs
+++ b/src/librustc/middle/trans/mod.rs
@@ -15,7 +15,6 @@ pub mod monomorphize;
 pub mod controlflow;
 pub mod glue;
 pub mod datum;
-pub mod write_guard;
 pub mod callee;
 pub mod expr;
 pub mod common;
diff --git a/src/librustc/middle/trans/write_guard.rs b/src/librustc/middle/trans/write_guard.rs
deleted file mode 100644
index 8f114827bfd..00000000000
--- a/src/librustc/middle/trans/write_guard.rs
+++ /dev/null
@@ -1,63 +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.
-
-//! Logic relating to rooting and write guards for managed values.
-//! This code is primarily for use by datum;
-//! it exists in its own module both to keep datum.rs bite-sized
-//! and for each in debugging (e.g., so you can use
-//! `RUST_LOG=rustc::middle::trans::write_guard`).
-
-
-use middle::borrowck::{RootInfo, root_map_key};
-use middle::trans::cleanup;
-use middle::trans::common::*;
-use middle::trans::datum::*;
-use syntax::codemap::Span;
-use syntax::ast;
-
-pub fn root_and_write_guard<'a, K:KindOps>(datum: &Datum<K>,
-                                           bcx: &'a Block<'a>,
-                                           span: Span,
-                                           expr_id: ast::NodeId,
-                                           derefs: uint) -> &'a Block<'a> {
-    let key = root_map_key { id: expr_id, derefs: derefs };
-    debug!("write_guard::root_and_write_guard(key={:?})", key);
-
-    // root the autoderef'd value, if necessary:
-    //
-    // (Note: root'd values are always boxes)
-    let ccx = bcx.ccx();
-    match ccx.maps.root_map.find(&key) {
-        None => bcx,
-        Some(&root_info) => root(datum, bcx, span, key, root_info)
-    }
-}
-
-fn root<'a, K:KindOps>(datum: &Datum<K>,
-                       bcx: &'a Block<'a>,
-                       _span: Span,
-                       root_key: root_map_key,
-                       root_info: RootInfo) -> &'a Block<'a> {
-    //! In some cases, borrowck will decide that an @T value must be
-    //! rooted for the program to be safe.  In that case, we will call
-    //! this function, which will stash a copy away until we exit the
-    //! scope `scope_id`.
-
-    debug!("write_guard::root(root_key={:?}, root_info={:?}, datum={:?})",
-           root_key, root_info, datum.to_str(bcx.ccx()));
-
-    // Root the datum. Note that we must zero this value,
-    // because sometimes we root on one path but not another.
-    // See e.g. #4904.
-    lvalue_scratch_datum(
-        bcx, datum.ty, "__write_guard", true,
-        cleanup::AstScope(root_info.scope), (),
-        |(), bcx, llval| datum.shallow_copy_and_take(bcx, llval)).bcx
-}
diff --git a/src/test/run-pass/borrowck-preserve-box-in-field.rs b/src/test/run-pass/borrowck-preserve-box-in-field.rs
deleted file mode 100644
index f05b8c67d77..00000000000
--- a/src/test/run-pass/borrowck-preserve-box-in-field.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-// ignore-pretty
-
-// Copyright 2012-2014 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.
-
-// exec-env:RUST_POISON_ON_FREE=1
-
-#![feature(managed_boxes)]
-
-fn borrow(x: &int, f: |x: &int|) {
-    let before = *x;
-    f(x);
-    let after = *x;
-    assert_eq!(before, after);
-}
-
-struct F { f: ~int }
-
-pub fn main() {
-    let mut x = @F {f: ~3};
-    borrow(x.f, |b_x| {
-        assert_eq!(*b_x, 3);
-        assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
-        x = @F {f: ~4};
-
-        println!("&*b_x = {:p}", &(*b_x));
-        assert_eq!(*b_x, 3);
-        assert!(&(*x.f) as *int != &(*b_x) as *int);
-    })
-}
diff --git a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs
deleted file mode 100644
index 0896d4de625..00000000000
--- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-// ignore-pretty
-
-// Copyright 2012-2014 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.
-
-// exec-env:RUST_POISON_ON_FREE=1
-
-#![feature(managed_boxes)]
-
-fn borrow(x: &int, f: |x: &int|) {
-    let before = *x;
-    f(x);
-    let after = *x;
-    assert_eq!(before, after);
-}
-
-struct F { f: ~int }
-
-pub fn main() {
-    let mut x = ~@F{f: ~3};
-    borrow(x.f, |b_x| {
-        assert_eq!(*b_x, 3);
-        assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
-        *x = @F{f: ~4};
-
-        println!("&*b_x = {:p}", &(*b_x));
-        assert_eq!(*b_x, 3);
-        assert!(&(*x.f) as *int != &(*b_x) as *int);
-    })
-}
diff --git a/src/test/run-pass/borrowck-preserve-box.rs b/src/test/run-pass/borrowck-preserve-box.rs
deleted file mode 100644
index cfb9a4b91df..00000000000
--- a/src/test/run-pass/borrowck-preserve-box.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-// ignore-pretty
-
-// Copyright 2012-2014 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.
-
-// exec-env:RUST_POISON_ON_FREE=1
-
-#![feature(managed_boxes)]
-
-fn borrow(x: &int, f: |x: &int|) {
-    let before = *x;
-    f(x);
-    let after = *x;
-    assert_eq!(before, after);
-}
-
-pub fn main() {
-    let mut x = @3;
-    borrow(x, |b_x| {
-        assert_eq!(*b_x, 3);
-        assert_eq!(&(*x) as *int, &(*b_x) as *int);
-        x = @22;
-
-        println!("&*b_x = {:p}", &(*b_x));
-        assert_eq!(*b_x, 3);
-        assert!(&(*x) as *int != &(*b_x) as *int);
-    })
-}
diff --git a/src/test/run-pass/borrowck-preserve-cond-box.rs b/src/test/run-pass/borrowck-preserve-cond-box.rs
deleted file mode 100644
index 52ea474dbf5..00000000000
--- a/src/test/run-pass/borrowck-preserve-cond-box.rs
+++ /dev/null
@@ -1,45 +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.
-
-// exec-env:RUST_POISON_ON_FREE=1
-
-#![feature(managed_boxes)]
-
-fn testfn(cond: bool) {
-    let mut x = @3;
-    let mut y = @4;
-
-    // borrow x and y
-    let r_x = &*x;
-    let r_y = &*y;
-    let mut r = r_x;
-    let mut exp = 3;
-
-    if cond {
-        r = r_y;
-        exp = 4;
-    }
-
-    println!("*r = {}, exp = {}", *r, exp);
-    assert_eq!(*r, exp);
-
-    x = @5;
-    y = @6;
-
-    println!("*r = {}, exp = {}", *r, exp);
-    assert_eq!(*r, exp);
-    assert_eq!(x, @5);
-    assert_eq!(y, @6);
-}
-
-pub fn main() {
-    testfn(true);
-    testfn(false);
-}
diff --git a/src/test/run-pass/borrowck-preserve-expl-deref.rs b/src/test/run-pass/borrowck-preserve-expl-deref.rs
deleted file mode 100644
index 749c8063950..00000000000
--- a/src/test/run-pass/borrowck-preserve-expl-deref.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-// ignore-pretty
-
-// Copyright 2012-2014 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.
-
-// exec-env:RUST_POISON_ON_FREE=1
-
-#![feature(managed_boxes)]
-
-fn borrow(x: &int, f: |x: &int|) {
-    let before = *x;
-    f(x);
-    let after = *x;
-    assert_eq!(before, after);
-}
-
-struct F { f: ~int }
-
-pub fn main() {
-    let mut x = @F {f: ~3};
-    borrow((*x).f, |b_x| {
-        assert_eq!(*b_x, 3);
-        assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
-        x = @F {f: ~4};
-
-        println!("&*b_x = {:p}", &(*b_x));
-        assert_eq!(*b_x, 3);
-        assert!(&(*x.f) as *int != &(*b_x) as *int);
-    })
-}