diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 5c50b8c55a9..7ed7735db45 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -419,7 +419,10 @@ impl<'a> CheckLoanCtxt<'a> { derefs: deref_count }; debug!("Inserting write guard at {:?}", key); - this.bccx.write_guard_map.insert(key); + let mut write_guard_map = this.bccx + .write_guard_map + .borrow_mut(); + write_guard_map.get().insert(key); } _ => {} diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index dc3dff0046e..431b7b0e2c8 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -82,7 +82,7 @@ pub fn check_crate( moved_variables_set: moved_variables_set, capture_map: capture_map, root_map: root_map(), - write_guard_map: @mut HashSet::new(), + write_guard_map: @RefCell::new(HashSet::new()), stats: @mut BorrowStats { loaned_paths_same: 0, loaned_paths_imm: 0, @@ -217,7 +217,7 @@ pub struct root_map_key { // A set containing IDs of expressions of gc'd type that need to have a write // guard. -pub type write_guard_map = @mut HashSet; +pub type write_guard_map = @RefCell>; pub type BckResult = Result; diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 43bbd3881f9..1b3a3d91838 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -123,7 +123,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt, root_map: @RefCell::new(HashMap::new()), method_map: @mut HashMap::new(), vtable_map: @RefCell::new(HashMap::new()), - write_guard_map: @mut HashSet::new(), + write_guard_map: @RefCell::new(HashSet::new()), capture_map: @RefCell::new(HashMap::new()) }; let e = match csearch::maybe_get_item_ast(tcx, enum_def, @@ -173,7 +173,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt, root_map: @RefCell::new(HashMap::new()), method_map: @mut HashMap::new(), vtable_map: @RefCell::new(HashMap::new()), - write_guard_map: @mut HashSet::new(), + write_guard_map: @RefCell::new(HashSet::new()), capture_map: @RefCell::new(HashMap::new()) }; let e = match csearch::maybe_get_item_ast(tcx, def_id, diff --git a/src/librustc/middle/trans/write_guard.rs b/src/librustc/middle/trans/write_guard.rs index 922abffac9e..3b60dc3dd37 100644 --- a/src/librustc/middle/trans/write_guard.rs +++ b/src/librustc/middle/trans/write_guard.rs @@ -56,7 +56,8 @@ pub fn root_and_write_guard(datum: &Datum, // Perform the write guard, if necessary. // // (Note: write-guarded values are always boxes) - if ccx.maps.write_guard_map.contains(&key) { + let write_guard_map = ccx.maps.write_guard_map.borrow(); + if write_guard_map.get().contains(&key) { perform_write_guard(datum, bcx, span) } else { bcx