rustc: Remove moved_variables_set

This commit is contained in:
Flavio Percoco
2014-04-23 00:59:42 +02:00
parent d10735e384
commit aff620de1e
9 changed files with 16 additions and 34 deletions
+1 -4
View File
@@ -348,8 +348,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
time(time_passes, "effect checking", (), |_|
middle::effect::check_crate(&ty_cx, krate));
let middle::moves::MoveMaps {moves_map, moved_variables_set,
capture_map} =
let middle::moves::MoveMaps {moves_map, capture_map} =
time(time_passes, "compute moves", (), |_|
middle::moves::compute_moves(&ty_cx, krate));
@@ -361,11 +360,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
time(time_passes, "borrow checking", (), |_|
middle::borrowck::check_crate(&ty_cx, &moves_map,
&moved_variables_set,
&capture_map, krate));
drop(moves_map);
drop(moved_variables_set);
time(time_passes, "kind checking", (), |_|
kind::check_crate(&ty_cx, krate));
-3
View File
@@ -77,13 +77,11 @@ fn visit_item(&mut self, item: &ast::Item, _: ()) {
pub fn check_crate(tcx: &ty::ctxt,
moves_map: &NodeSet,
moved_variables_set: &NodeSet,
capture_map: &moves::CaptureMap,
krate: &ast::Crate) {
let mut bccx = BorrowckCtxt {
tcx: tcx,
moves_map: moves_map,
moved_variables_set: moved_variables_set,
capture_map: capture_map,
stats: @BorrowStats {
loaned_paths_same: Cell::new(0),
@@ -168,7 +166,6 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
pub struct BorrowckCtxt<'a> {
tcx: &'a ty::ctxt,
moves_map: &'a NodeSet,
moved_variables_set: &'a NodeSet,
capture_map: &'a moves::CaptureMap,
// Statistics:
+1 -20
View File
@@ -101,11 +101,6 @@ struct Foo { a: int, b: ~int }
expressions that are moved. It is more efficient therefore just to
store those entries.
Sometimes though we want to know the variables that are moved (in
particular in the borrow checker). For these cases, the set
`moved_variables_set` just collects the ids of variables that are
moved.
Finally, the `capture_map` maps from the node_id of a closure
expression to an array of `CaptureVar` structs detailing which
variables are captured and how (by ref, by copy, by move).
@@ -170,7 +165,6 @@ pub struct MoveMaps {
* pub Note: The `moves_map` stores expression ids that are moves,
* whereas this set stores the ids of the variables that are
* moved at some point */
pub moved_variables_set: NodeSet,
pub capture_map: CaptureMap
}
@@ -206,7 +200,6 @@ pub fn compute_moves(tcx: &ty::ctxt, krate: &Crate) -> MoveMaps {
tcx: tcx,
move_maps: MoveMaps {
moves_map: NodeSet::new(),
moved_variables_set: NodeSet::new(),
capture_map: NodeMap::new()
}
};
@@ -326,19 +319,6 @@ pub fn use_expr(&mut self,
debug!("comp_mode = {:?}", comp_mode);
match expr.node {
ExprPath(..) => {
match comp_mode {
Move => {
let def = self.tcx.def_map.borrow().get_copy(&expr.id);
let r = moved_variable_node_id_from_def(def);
for &id in r.iter() {
self.move_maps.moved_variables_set.insert(id);
}
}
Read => {}
}
}
ExprUnary(UnDeref, base) => { // *base
if !self.use_overloaded_operator(expr, base, []) {
// Moving out of *base moves out of base.
@@ -475,6 +455,7 @@ fn has_dtor(tcx: &ty::ctxt, ty: ty::t) -> bool {
self.use_expr(base, Read);
}
ExprPath(..) |
ExprInlineAsm(..) |
ExprBreak(..) |
ExprAgain(..) |
@@ -26,8 +26,10 @@ struct F { f: ~int }
pub fn main() {
let mut x = @F {f: ~3};
borrow(x.f, |b_x| {
//~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable
assert_eq!(*b_x, 3);
assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
//~^ NOTE borrow occurs due to use of `x` in closure
x = @F {f: ~4};
println!("&*b_x = {:p}", &(*b_x));
@@ -26,8 +26,10 @@ struct F { f: ~int }
pub fn main() {
let mut x = ~@F{f: ~3};
borrow(x.f, |b_x| {
//~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable
assert_eq!(*b_x, 3);
assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
//~^ NOTE borrow occurs due to use of `x` in closure
*x = @F{f: ~4};
println!("&*b_x = {:p}", &(*b_x));
@@ -24,8 +24,10 @@ fn borrow(x: &int, f: |x: &int|) {
pub fn main() {
let mut x = @3;
borrow(x, |b_x| {
//~^ ERROR cannot borrow `x` as mutable because `*x` is also borrowed as immutable
assert_eq!(*b_x, 3);
assert_eq!(&(*x) as *int, &(*b_x) as *int);
//~^ NOTE borrow occurs due to use of `x` in closure
x = @22;
println!("&*b_x = {:p}", &(*b_x));
@@ -30,8 +30,8 @@ fn testfn(cond: bool) {
println!("*r = {}, exp = {}", *r, exp);
assert_eq!(*r, exp);
x = @5;
y = @6;
x = @5; //~ERROR cannot assign to `x` because it is borrowed
y = @6; //~ERROR cannot assign to `y` because it is borrowed
println!("*r = {}, exp = {}", *r, exp);
assert_eq!(*r, exp);
@@ -26,8 +26,10 @@ struct F { f: ~int }
pub fn main() {
let mut x = @F {f: ~3};
borrow((*x).f, |b_x| {
//~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable
assert_eq!(*b_x, 3);
assert_eq!(&(*x.f) as *int, &(*b_x) as *int);
//~^ NOTE borrow occurs due to use of `x` in closure
x = @F {f: ~4};
println!("&*b_x = {:p}", &(*b_x));
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
/* Tests conditional rooting of the box y */
// Test no-special rooting is used for managed boxes
#![feature(managed_boxes)]
@@ -25,12 +25,11 @@ fn testfn(cond: bool) {
exp = 4;
}
x = @5;
y = @6;
x = @5; //~ERROR cannot assign to `x` because it is borrowed
y = @6; //~ERROR cannot assign to `y` because it is borrowed
assert_eq!(*a, exp);
assert_eq!(x, @5);
assert_eq!(y, @6);
}
pub fn main() {
}
pub fn main() {}