@@ -313,7 +313,7 @@ struct ctxt_ {
313
313
enum_var_cache : RefCell < HashMap < DefId , @~[ @VariantInfo ] > > ,
314
314
ty_param_defs : RefCell < HashMap < ast:: NodeId , TypeParameterDef > > ,
315
315
adjustments : RefCell < HashMap < ast:: NodeId , @AutoAdjustment > > ,
316
- normalized_cache : @ mut HashMap < t , t > ,
316
+ normalized_cache : RefCell < HashMap < t , t > > ,
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 > > ,
@@ -961,10 +961,6 @@ fn mk_rcache() -> creader_cache {
961
961
return @mut HashMap :: new ( ) ;
962
962
}
963
963
964
- pub fn new_ty_hash < V : ' static > ( ) -> @mut HashMap < t , V > {
965
- @mut HashMap :: new ( )
966
- }
967
-
968
964
pub fn mk_ctxt ( s : session:: Session ,
969
965
dm : resolve:: DefMap ,
970
966
named_region_map : @mut resolve_lifetime:: NamedRegionMap ,
@@ -1003,7 +999,7 @@ pub fn mk_ctxt(s: session::Session,
1003
999
impl_trait_cache : RefCell :: new ( HashMap :: new ( ) ) ,
1004
1000
ty_param_defs : RefCell :: new ( HashMap :: new ( ) ) ,
1005
1001
adjustments : RefCell :: new ( HashMap :: new ( ) ) ,
1006
- normalized_cache : new_ty_hash ( ) ,
1002
+ normalized_cache : RefCell :: new ( HashMap :: new ( ) ) ,
1007
1003
lang_items : lang_items,
1008
1004
provided_method_sources : RefCell :: new ( HashMap :: new ( ) ) ,
1009
1005
supertraits : RefCell :: new ( HashMap :: new ( ) ) ,
@@ -4265,13 +4261,20 @@ pub fn normalize_ty(cx: ctxt, t: t) -> t {
4265
4261
fn tcx ( & self ) -> ty:: ctxt { * * self }
4266
4262
4267
4263
fn fold_ty ( & mut self , t : ty:: t ) -> ty:: t {
4268
- match self . tcx ( ) . normalized_cache . find_copy ( & t) {
4264
+ let normalized_opt = {
4265
+ let normalized_cache = self . tcx ( ) . normalized_cache . borrow ( ) ;
4266
+ normalized_cache. get ( ) . find_copy ( & t)
4267
+ } ;
4268
+ match normalized_opt {
4269
4269
Some ( u) => {
4270
4270
return u;
4271
4271
}
4272
4272
None => {
4273
4273
let t_norm = ty_fold:: super_fold_ty ( self , t) ;
4274
- self . tcx ( ) . normalized_cache . insert ( t, t_norm) ;
4274
+ let mut normalized_cache = self . tcx ( )
4275
+ . normalized_cache
4276
+ . borrow_mut ( ) ;
4277
+ normalized_cache. get ( ) . insert ( t, t_norm) ;
4275
4278
return t_norm;
4276
4279
}
4277
4280
}
0 commit comments