@@ -317,7 +317,7 @@ struct ctxt_ {
317
317
lang_items : middle:: lang_items:: LanguageItems ,
318
318
// A mapping of fake provided method def_ids to the default implementation
319
319
provided_method_sources : RefCell < HashMap < ast:: DefId , ast:: DefId > > ,
320
- supertraits : @ mut HashMap < ast:: DefId , @~[ @TraitRef ] > ,
320
+ supertraits : RefCell < HashMap < ast:: DefId , @~[ @TraitRef ] > > ,
321
321
322
322
// Maps from def-id of a type or region parameter to its
323
323
// (inferred) variance.
@@ -1006,7 +1006,7 @@ pub fn mk_ctxt(s: session::Session,
1006
1006
normalized_cache : new_ty_hash ( ) ,
1007
1007
lang_items : lang_items,
1008
1008
provided_method_sources : RefCell :: new ( HashMap :: new ( ) ) ,
1009
- supertraits : @ mut HashMap :: new ( ) ,
1009
+ supertraits : RefCell :: new ( HashMap :: new ( ) ) ,
1010
1010
destructor_for_type : @mut HashMap :: new ( ) ,
1011
1011
destructors : @mut HashSet :: new ( ) ,
1012
1012
trait_impls : @mut HashMap :: new ( ) ,
@@ -3552,13 +3552,14 @@ pub fn provided_trait_methods(cx: ctxt, id: ast::DefId) -> ~[@Method] {
3552
3552
}
3553
3553
}
3554
3554
3555
- pub fn trait_supertraits ( cx : ctxt ,
3556
- id : ast:: DefId ) -> @~[ @TraitRef ]
3557
- {
3555
+ pub fn trait_supertraits ( cx : ctxt , id : ast:: DefId ) -> @~[ @TraitRef ] {
3558
3556
// Check the cache.
3559
- match cx. supertraits . find ( & id) {
3560
- Some ( & trait_refs) => { return trait_refs; }
3561
- None => { } // Continue.
3557
+ {
3558
+ let supertraits = cx. supertraits . borrow ( ) ;
3559
+ match supertraits. get ( ) . find ( & id) {
3560
+ Some ( & trait_refs) => { return trait_refs; }
3561
+ None => { } // Continue.
3562
+ }
3562
3563
}
3563
3564
3564
3565
// Not in the cache. It had better be in the metadata, which means it
@@ -3568,7 +3569,8 @@ pub fn trait_supertraits(cx: ctxt,
3568
3569
// Get the supertraits out of the metadata and create the
3569
3570
// TraitRef for each.
3570
3571
let result = @csearch:: get_supertraits ( cx, id) ;
3571
- cx. supertraits . insert ( id, result) ;
3572
+ let mut supertraits = cx. supertraits . borrow_mut ( ) ;
3573
+ supertraits. get ( ) . insert ( id, result) ;
3572
3574
return result;
3573
3575
}
3574
3576
0 commit comments