Skip to content

Commit bc1ea78

Browse files
committed
librustc: De-@mut the write guard map
1 parent b5b403a commit bc1ea78

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,10 @@ impl<'a> CheckLoanCtxt<'a> {
419419
derefs: deref_count
420420
};
421421
debug!("Inserting write guard at {:?}", key);
422-
this.bccx.write_guard_map.insert(key);
422+
let mut write_guard_map = this.bccx
423+
.write_guard_map
424+
.borrow_mut();
425+
write_guard_map.get().insert(key);
423426
}
424427

425428
_ => {}

src/librustc/middle/borrowck/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn check_crate(
8282
moved_variables_set: moved_variables_set,
8383
capture_map: capture_map,
8484
root_map: root_map(),
85-
write_guard_map: @mut HashSet::new(),
85+
write_guard_map: @RefCell::new(HashSet::new()),
8686
stats: @mut BorrowStats {
8787
loaned_paths_same: 0,
8888
loaned_paths_imm: 0,
@@ -217,7 +217,7 @@ pub struct root_map_key {
217217

218218
// A set containing IDs of expressions of gc'd type that need to have a write
219219
// guard.
220-
pub type write_guard_map = @mut HashSet<root_map_key>;
220+
pub type write_guard_map = @RefCell<HashSet<root_map_key>>;
221221

222222
pub type BckResult<T> = Result<T, BckError>;
223223

src/librustc/middle/const_eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
123123
root_map: @RefCell::new(HashMap::new()),
124124
method_map: @mut HashMap::new(),
125125
vtable_map: @RefCell::new(HashMap::new()),
126-
write_guard_map: @mut HashSet::new(),
126+
write_guard_map: @RefCell::new(HashSet::new()),
127127
capture_map: @RefCell::new(HashMap::new())
128128
};
129129
let e = match csearch::maybe_get_item_ast(tcx, enum_def,
@@ -173,7 +173,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
173173
root_map: @RefCell::new(HashMap::new()),
174174
method_map: @mut HashMap::new(),
175175
vtable_map: @RefCell::new(HashMap::new()),
176-
write_guard_map: @mut HashSet::new(),
176+
write_guard_map: @RefCell::new(HashSet::new()),
177177
capture_map: @RefCell::new(HashMap::new())
178178
};
179179
let e = match csearch::maybe_get_item_ast(tcx, def_id,

src/librustc/middle/trans/write_guard.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ pub fn root_and_write_guard(datum: &Datum,
5656
// Perform the write guard, if necessary.
5757
//
5858
// (Note: write-guarded values are always boxes)
59-
if ccx.maps.write_guard_map.contains(&key) {
59+
let write_guard_map = ccx.maps.write_guard_map.borrow();
60+
if write_guard_map.get().contains(&key) {
6061
perform_write_guard(datum, bcx, span)
6162
} else {
6263
bcx

0 commit comments

Comments
 (0)