diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 431b7b0e2c8..d0a3be055d1 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -475,7 +475,8 @@ impl BorrowckCtxt { } pub fn is_move(&self, id: ast::NodeId) -> bool { - self.moves_map.contains(&id) + let moves_map = self.moves_map.borrow(); + moves_map.get().contains(&id) } pub fn cat_expr(&self, expr: @ast::Expr) -> mc::cmt { diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 948c7932ca0..116d0155084 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -889,7 +889,8 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, by_ref_span = Some(span); } BindByValue(_) => { - if cx.moves_map.contains(&id) { + let moves_map = cx.moves_map.borrow(); + if moves_map.get().contains(&id) { any_by_move = true; } } @@ -926,7 +927,8 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, if pat_is_binding(def_map, p) { match p.node { PatIdent(_, _, sub) => { - if cx.moves_map.contains(&p.id) { + let moves_map = cx.moves_map.borrow(); + if moves_map.get().contains(&p.id) { check_move(p, sub); } } diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index f36b283f1e4..29e59ba5c45 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -161,7 +161,7 @@ pub struct CaptureVar { pub type CaptureMap = @RefCell>; -pub type MovesMap = @mut HashSet; +pub type MovesMap = @RefCell>; /** * Set of variable node-ids that are moved. @@ -215,7 +215,7 @@ pub fn compute_moves(tcx: ty::ctxt, tcx: tcx, method_map: method_map, move_maps: MoveMaps { - moves_map: @mut HashSet::new(), + moves_map: @RefCell::new(HashSet::new()), capture_map: @RefCell::new(HashMap::new()), moved_variables_set: @mut HashSet::new() } @@ -283,7 +283,10 @@ impl VisitContext { let expr_ty = ty::expr_ty_adjusted(self.tcx, expr); if ty::type_moves_by_default(self.tcx, expr_ty) { - self.move_maps.moves_map.insert(expr.id); + { + let mut moves_map = self.move_maps.moves_map.borrow_mut(); + moves_map.get().insert(expr.id); + } self.use_expr(expr, Move); } else { self.use_expr(expr, Read); @@ -388,7 +391,12 @@ impl VisitContext { // closures should be noncopyable, they shouldn't move by default; // calling a closure should only consume it if it's once. if mode == Move { - self.move_maps.moves_map.insert(callee.id); + { + let mut moves_map = self.move_maps + .moves_map + .borrow_mut(); + moves_map.get().insert(callee.id); + } } self.use_expr(callee, mode); self.use_fn_args(callee.id, *args); @@ -643,7 +651,10 @@ impl VisitContext { id, bm, binding_moves); if binding_moves { - self.move_maps.moves_map.insert(id); + { + let mut moves_map = self.move_maps.moves_map.borrow_mut(); + moves_map.get().insert(id); + } } }) }