@@ -650,9 +650,7 @@ pub struct ctxt<'tcx> {
650
650
/// A cache for the trait_items() routine
651
651
pub trait_items_cache : RefCell < DefIdMap < Rc < Vec < ImplOrTraitItem < ' tcx > > > > > ,
652
652
653
- pub impl_trait_cache : RefCell < DefIdMap < Option < TraitRef < ' tcx > > > > ,
654
-
655
- pub impl_trait_refs : RefCell < NodeMap < TraitRef < ' tcx > > > ,
653
+ pub impl_trait_refs : RefCell < DefIdMap < Option < TraitRef < ' tcx > > > > ,
656
654
pub trait_defs : RefCell < DefIdMap < & ' tcx TraitDef < ' tcx > > > ,
657
655
658
656
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
@@ -675,7 +673,6 @@ pub struct ctxt<'tcx> {
675
673
pub freevars : RefCell < FreevarMap > ,
676
674
pub tcache : RefCell < DefIdMap < TypeScheme < ' tcx > > > ,
677
675
pub rcache : RefCell < FnvHashMap < creader_cache_key , Ty < ' tcx > > > ,
678
- pub short_names_cache : RefCell < FnvHashMap < Ty < ' tcx > , String > > ,
679
676
pub tc_cache : RefCell < FnvHashMap < Ty < ' tcx > , TypeContents > > ,
680
677
pub ast_ty_to_ty_cache : RefCell < NodeMap < Ty < ' tcx > > > ,
681
678
pub enum_var_cache : RefCell < DefIdMap < Rc < Vec < Rc < VariantInfo < ' tcx > > > > > > ,
@@ -2741,7 +2738,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
2741
2738
def_map : def_map,
2742
2739
node_types : RefCell :: new ( FnvHashMap ( ) ) ,
2743
2740
item_substs : RefCell :: new ( NodeMap ( ) ) ,
2744
- impl_trait_refs : RefCell :: new ( NodeMap ( ) ) ,
2741
+ impl_trait_refs : RefCell :: new ( DefIdMap ( ) ) ,
2745
2742
trait_defs : RefCell :: new ( DefIdMap ( ) ) ,
2746
2743
predicates : RefCell :: new ( DefIdMap ( ) ) ,
2747
2744
super_predicates : RefCell :: new ( DefIdMap ( ) ) ,
@@ -2750,14 +2747,12 @@ pub fn mk_ctxt<'tcx>(s: Session,
2750
2747
freevars : freevars,
2751
2748
tcache : RefCell :: new ( DefIdMap ( ) ) ,
2752
2749
rcache : RefCell :: new ( FnvHashMap ( ) ) ,
2753
- short_names_cache : RefCell :: new ( FnvHashMap ( ) ) ,
2754
2750
tc_cache : RefCell :: new ( FnvHashMap ( ) ) ,
2755
2751
ast_ty_to_ty_cache : RefCell :: new ( NodeMap ( ) ) ,
2756
2752
enum_var_cache : RefCell :: new ( DefIdMap ( ) ) ,
2757
2753
impl_or_trait_items : RefCell :: new ( DefIdMap ( ) ) ,
2758
2754
trait_item_def_ids : RefCell :: new ( DefIdMap ( ) ) ,
2759
2755
trait_items_cache : RefCell :: new ( DefIdMap ( ) ) ,
2760
- impl_trait_cache : RefCell :: new ( DefIdMap ( ) ) ,
2761
2756
ty_param_defs : RefCell :: new ( NodeMap ( ) ) ,
2762
2757
adjustments : RefCell :: new ( NodeMap ( ) ) ,
2763
2758
normalized_cache : RefCell :: new ( FnvHashMap ( ) ) ,
@@ -4464,16 +4459,6 @@ pub fn named_element_ty<'tcx>(cx: &ctxt<'tcx>,
4464
4459
}
4465
4460
}
4466
4461
4467
- pub fn impl_id_to_trait_ref < ' tcx > ( cx : & ctxt < ' tcx > , id : ast:: NodeId )
4468
- -> ty:: TraitRef < ' tcx > {
4469
- match cx. impl_trait_refs . borrow ( ) . get ( & id) {
4470
- Some ( ty) => * ty,
4471
- None => cx. sess . bug (
4472
- & format ! ( "impl_id_to_trait_ref: no trait ref for impl `{}`" ,
4473
- cx. map. node_to_string( id) ) )
4474
- }
4475
- }
4476
-
4477
4462
pub fn node_id_to_type < ' tcx > ( cx : & ctxt < ' tcx > , id : ast:: NodeId ) -> Ty < ' tcx > {
4478
4463
match node_id_to_type_opt ( cx, id) {
4479
4464
Some ( ty) => ty,
@@ -5268,12 +5253,12 @@ pub fn associated_consts<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
5268
5253
/// the future).
5269
5254
fn lookup_locally_or_in_crate_store < V , F > ( descr : & str ,
5270
5255
def_id : ast:: DefId ,
5271
- map : & mut DefIdMap < V > ,
5256
+ map : & RefCell < DefIdMap < V > > ,
5272
5257
load_external : F ) -> V where
5273
5258
V : Clone ,
5274
5259
F : FnOnce ( ) -> V ,
5275
5260
{
5276
- match map. get ( & def_id) . cloned ( ) {
5261
+ match map. borrow ( ) . get ( & def_id) . cloned ( ) {
5277
5262
Some ( v) => { return v; }
5278
5263
None => { }
5279
5264
}
@@ -5282,7 +5267,7 @@ fn lookup_locally_or_in_crate_store<V, F>(descr: &str,
5282
5267
panic ! ( "No def'n found for {:?} in tcx.{}" , def_id, descr) ;
5283
5268
}
5284
5269
let v = load_external ( ) ;
5285
- map. insert ( def_id, v. clone ( ) ) ;
5270
+ map. borrow_mut ( ) . insert ( def_id, v. clone ( ) ) ;
5286
5271
v
5287
5272
}
5288
5273
@@ -5348,13 +5333,9 @@ pub fn custom_coerce_unsized_kind<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId)
5348
5333
5349
5334
pub fn impl_or_trait_item < ' tcx > ( cx : & ctxt < ' tcx > , id : ast:: DefId )
5350
5335
-> ImplOrTraitItem < ' tcx > {
5351
- lookup_locally_or_in_crate_store ( "impl_or_trait_items" ,
5352
- id,
5353
- & mut * cx. impl_or_trait_items
5354
- . borrow_mut ( ) ,
5355
- || {
5356
- csearch:: get_impl_or_trait_item ( cx, id)
5357
- } )
5336
+ lookup_locally_or_in_crate_store (
5337
+ "impl_or_trait_items" , id, & cx. impl_or_trait_items ,
5338
+ || csearch:: get_impl_or_trait_item ( cx, id) )
5358
5339
}
5359
5340
5360
5341
/// Returns the parameter index that the given associated type corresponds to.
@@ -5881,37 +5862,35 @@ pub fn lookup_item_type<'tcx>(cx: &ctxt<'tcx>,
5881
5862
did : ast:: DefId )
5882
5863
-> TypeScheme < ' tcx > {
5883
5864
lookup_locally_or_in_crate_store (
5884
- "tcache" , did, & mut * cx. tcache . borrow_mut ( ) ,
5865
+ "tcache" , did, & cx. tcache ,
5885
5866
|| csearch:: get_type ( cx, did) )
5886
5867
}
5887
5868
5888
5869
/// Given the did of a trait, returns its canonical trait ref.
5889
5870
pub fn lookup_trait_def < ' tcx > ( cx : & ctxt < ' tcx > , did : ast:: DefId )
5890
5871
-> & ' tcx TraitDef < ' tcx > {
5891
- memoized ( & cx . trait_defs , did , | did : DefId | {
5892
- assert ! ( did. krate != ast :: LOCAL_CRATE ) ;
5893
- cx. arenas . trait_defs . alloc ( csearch:: get_trait_def ( cx, did) )
5894
- } )
5872
+ lookup_locally_or_in_crate_store (
5873
+ "trait_defs" , did, & cx . trait_defs ,
5874
+ || cx. arenas . trait_defs . alloc ( csearch:: get_trait_def ( cx, did) )
5875
+ )
5895
5876
}
5896
5877
5897
5878
/// Given the did of an item, returns its full set of predicates.
5898
5879
pub fn lookup_predicates < ' tcx > ( cx : & ctxt < ' tcx > , did : ast:: DefId )
5899
5880
-> GenericPredicates < ' tcx >
5900
5881
{
5901
- memoized ( & cx. predicates , did, |did : DefId | {
5902
- assert ! ( did. krate != ast:: LOCAL_CRATE ) ;
5903
- csearch:: get_predicates ( cx, did)
5904
- } )
5882
+ lookup_locally_or_in_crate_store (
5883
+ "predicates" , did, & cx. predicates ,
5884
+ || csearch:: get_predicates ( cx, did) )
5905
5885
}
5906
5886
5907
5887
/// Given the did of a trait, returns its superpredicates.
5908
5888
pub fn lookup_super_predicates < ' tcx > ( cx : & ctxt < ' tcx > , did : ast:: DefId )
5909
5889
-> GenericPredicates < ' tcx >
5910
5890
{
5911
- memoized ( & cx. super_predicates , did, |did : DefId | {
5912
- assert ! ( did. krate != ast:: LOCAL_CRATE ) ;
5913
- csearch:: get_super_predicates ( cx, did)
5914
- } )
5891
+ lookup_locally_or_in_crate_store (
5892
+ "super_predicates" , did, & cx. super_predicates ,
5893
+ || csearch:: get_super_predicates ( cx, did) )
5915
5894
}
5916
5895
5917
5896
pub fn predicates < ' tcx > (
@@ -6281,7 +6260,7 @@ pub fn required_region_bounds<'tcx>(tcx: &ctxt<'tcx>,
6281
6260
6282
6261
pub fn item_variances ( tcx : & ctxt , item_id : ast:: DefId ) -> Rc < ItemVariances > {
6283
6262
lookup_locally_or_in_crate_store (
6284
- "item_variance_map" , item_id, & mut * tcx. item_variance_map . borrow_mut ( ) ,
6263
+ "item_variance_map" , item_id, & tcx. item_variance_map ,
6285
6264
|| Rc :: new ( csearch:: get_item_variances ( & tcx. sess . cstore , item_id) ) )
6286
6265
}
6287
6266
0 commit comments