Skip to content

Commit 214d6bc

Browse files
committed
librustc: De-@mut the trait_method_def_ids table.
1 parent f15f938 commit 214d6bc

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/librustc/middle/ty.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ struct ctxt_ {
290290
methods: RefCell<HashMap<DefId, @Method>>,
291291

292292
// Maps from a trait def-id to a list of the def-ids of its methods
293-
trait_method_def_ids: @mut HashMap<DefId, @~[DefId]>,
293+
trait_method_def_ids: RefCell<HashMap<DefId, @~[DefId]>>,
294294

295295
// A cache for the trait_methods() routine
296296
trait_methods_cache: @mut HashMap<DefId, @~[@Method]>,
@@ -999,7 +999,7 @@ pub fn mk_ctxt(s: session::Session,
999999
ast_ty_to_ty_cache: @mut HashMap::new(),
10001000
enum_var_cache: @mut HashMap::new(),
10011001
methods: RefCell::new(HashMap::new()),
1002-
trait_method_def_ids: @mut HashMap::new(),
1002+
trait_method_def_ids: RefCell::new(HashMap::new()),
10031003
trait_methods_cache: @mut HashMap::new(),
10041004
impl_trait_cache: @mut HashMap::new(),
10051005
ty_param_defs: @mut HashMap::new(),
@@ -3610,9 +3610,13 @@ pub fn method(cx: ctxt, id: ast::DefId) -> @Method {
36103610
}
36113611

36123612
pub fn trait_method_def_ids(cx: ctxt, id: ast::DefId) -> @~[DefId] {
3613-
lookup_locally_or_in_crate_store(
3614-
"trait_method_def_ids", id, cx.trait_method_def_ids,
3615-
|| @csearch::get_trait_method_def_ids(cx.cstore, id))
3613+
let mut trait_method_def_ids = cx.trait_method_def_ids.borrow_mut();
3614+
lookup_locally_or_in_crate_store("trait_method_def_ids",
3615+
id,
3616+
trait_method_def_ids.get(),
3617+
|| {
3618+
@csearch::get_trait_method_def_ids(cx.cstore, id)
3619+
})
36163620
}
36173621

36183622
pub fn impl_trait_ref(cx: ctxt, id: ast::DefId) -> Option<@TraitRef> {

src/librustc/middle/typeck/collect.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
226226
});
227227

228228
let trait_def_id = local_def(trait_id);
229-
tcx.trait_method_def_ids.insert(trait_def_id, method_def_ids);
229+
let mut trait_method_def_ids = tcx.trait_method_def_ids
230+
.borrow_mut();
231+
trait_method_def_ids.get().insert(trait_def_id, method_def_ids);
230232
}
231233
_ => { /* Ignore things that aren't traits */ }
232234
}

0 commit comments

Comments
 (0)