@@ -295,7 +295,7 @@ struct ctxt_ {
295
295
// A cache for the trait_methods() routine
296
296
trait_methods_cache : RefCell < HashMap < DefId , @~[ @Method ] > > ,
297
297
298
- impl_trait_cache : @ mut HashMap < ast:: DefId , Option < @ty:: TraitRef > > ,
298
+ impl_trait_cache : RefCell < HashMap < ast:: DefId , Option < @ty:: TraitRef > > > ,
299
299
300
300
trait_refs : @mut HashMap < NodeId , @TraitRef > ,
301
301
trait_defs : @mut HashMap < DefId , @TraitDef > ,
@@ -1001,7 +1001,7 @@ pub fn mk_ctxt(s: session::Session,
1001
1001
methods : RefCell :: new ( HashMap :: new ( ) ) ,
1002
1002
trait_method_def_ids : RefCell :: new ( HashMap :: new ( ) ) ,
1003
1003
trait_methods_cache : RefCell :: new ( HashMap :: new ( ) ) ,
1004
- impl_trait_cache : @ mut HashMap :: new ( ) ,
1004
+ impl_trait_cache : RefCell :: new ( HashMap :: new ( ) ) ,
1005
1005
ty_param_defs : @mut HashMap :: new ( ) ,
1006
1006
adjustments : @mut HashMap :: new ( ) ,
1007
1007
normalized_cache : new_ty_hash ( ) ,
@@ -3621,10 +3621,14 @@ pub fn trait_method_def_ids(cx: ctxt, id: ast::DefId) -> @~[DefId] {
3621
3621
}
3622
3622
3623
3623
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
+ }
3627
3630
}
3631
+
3628
3632
let ret = if id. crate == ast:: LOCAL_CRATE {
3629
3633
debug ! ( "(impl_trait_ref) searching for trait impl {:?}" , id) ;
3630
3634
match cx. items . find ( & id. node ) {
@@ -3642,7 +3646,9 @@ pub fn impl_trait_ref(cx: ctxt, id: ast::DefId) -> Option<@TraitRef> {
3642
3646
} else {
3643
3647
csearch:: get_impl_trait ( cx, id)
3644
3648
} ;
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) ;
3646
3652
return ret;
3647
3653
}
3648
3654
0 commit comments