From 522743c9dbf561ed026e917d9911d94fad5d19a5 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 21 Dec 2013 17:20:42 -0800 Subject: [PATCH] librustc: De-`@mut` the moved variables set --- src/librustc/middle/borrowck/gather_loans/lifetime.rs | 5 ++++- src/librustc/middle/moves.rs | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/librustc/middle/borrowck/gather_loans/lifetime.rs b/src/librustc/middle/borrowck/gather_loans/lifetime.rs index a4911ca556f..38598e8b78f 100644 --- a/src/librustc/middle/borrowck/gather_loans/lifetime.rs +++ b/src/librustc/middle/borrowck/gather_loans/lifetime.rs @@ -305,7 +305,10 @@ impl<'a> GuaranteeLifetimeContext<'a> { mc::cat_local(id) | mc::cat_self(id) | mc::cat_arg(id) => { - self.bccx.moved_variables_set.contains(&id) + let moved_variables_set = self.bccx + .moved_variables_set + .borrow(); + moved_variables_set.get().contains(&id) } mc::cat_rvalue(..) | mc::cat_static_item | diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index 29e59ba5c45..52c20ba2819 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -169,7 +169,7 @@ pub type MovesMap = @RefCell>; * Note: The `VariableMovesMap` stores expression ids that * are moves, whereas this set stores the ids of the variables * that are moved at some point */ -pub type MovedVariablesSet = @mut HashSet; +pub type MovedVariablesSet = @RefCell>; /** See the section Output on the module comment for explanation. */ #[deriving(Clone)] @@ -217,7 +217,7 @@ pub fn compute_moves(tcx: ty::ctxt, move_maps: MoveMaps { moves_map: @RefCell::new(HashSet::new()), capture_map: @RefCell::new(HashMap::new()), - moved_variables_set: @mut HashSet::new() + moved_variables_set: @RefCell::new(HashSet::new()) } }; let visit_cx = &mut visit_cx; @@ -344,7 +344,11 @@ impl VisitContext { let def = self.tcx.def_map.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); + let mut moved_variables_set = + self.move_maps + .moved_variables_set + .borrow_mut(); + moved_variables_set.get().insert(id); } } Read => {}