Skip to content

Commit efdbd60

Browse files
committed
librustc: De-@mut the impl_trait_cache
1 parent 02f13ad commit efdbd60

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/librustc/middle/ty.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ struct ctxt_ {
295295
// A cache for the trait_methods() routine
296296
trait_methods_cache: RefCell<HashMap<DefId, @~[@Method]>>,
297297

298-
impl_trait_cache: @mut HashMap<ast::DefId, Option<@ty::TraitRef>>,
298+
impl_trait_cache: RefCell<HashMap<ast::DefId, Option<@ty::TraitRef>>>,
299299

300300
trait_refs: @mut HashMap<NodeId, @TraitRef>,
301301
trait_defs: @mut HashMap<DefId, @TraitDef>,
@@ -1001,7 +1001,7 @@ pub fn mk_ctxt(s: session::Session,
10011001
methods: RefCell::new(HashMap::new()),
10021002
trait_method_def_ids: RefCell::new(HashMap::new()),
10031003
trait_methods_cache: RefCell::new(HashMap::new()),
1004-
impl_trait_cache: @mut HashMap::new(),
1004+
impl_trait_cache: RefCell::new(HashMap::new()),
10051005
ty_param_defs: @mut HashMap::new(),
10061006
adjustments: @mut HashMap::new(),
10071007
normalized_cache: new_ty_hash(),
@@ -3621,10 +3621,14 @@ pub fn trait_method_def_ids(cx: ctxt, id: ast::DefId) -> @~[DefId] {
36213621
}
36223622

36233623
pub fn impl_trait_ref(cx: ctxt, id: ast::DefId) -> Option<@TraitRef> {
3624-
match cx.impl_trait_cache.find(&id) {
3625-
Some(&ret) => { return ret; }
3626-
None => {}
3624+
{
3625+
let mut impl_trait_cache = cx.impl_trait_cache.borrow_mut();
3626+
match impl_trait_cache.get().find(&id) {
3627+
Some(&ret) => { return ret; }
3628+
None => {}
3629+
}
36273630
}
3631+
36283632
let ret = if id.crate == ast::LOCAL_CRATE {
36293633
debug!("(impl_trait_ref) searching for trait impl {:?}", id);
36303634
match cx.items.find(&id.node) {
@@ -3642,7 +3646,9 @@ pub fn impl_trait_ref(cx: ctxt, id: ast::DefId) -> Option<@TraitRef> {
36423646
} else {
36433647
csearch::get_impl_trait(cx, id)
36443648
};
3645-
cx.impl_trait_cache.insert(id, ret);
3649+
3650+
let mut impl_trait_cache = cx.impl_trait_cache.borrow_mut();
3651+
impl_trait_cache.get().insert(id, ret);
36463652
return ret;
36473653
}
36483654

0 commit comments

Comments
 (0)