@@ -650,9 +650,7 @@ pub struct ctxt<'tcx> {
650650 /// A cache for the trait_items() routine
651651 pub trait_items_cache : RefCell < DefIdMap < Rc < Vec < ImplOrTraitItem < ' tcx > > > > > ,
652652
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 > > > > ,
656654 pub trait_defs : RefCell < DefIdMap < & ' tcx TraitDef < ' tcx > > > ,
657655
658656 /// Maps from the def-id of an item (trait/struct/enum/fn) to its
@@ -675,7 +673,6 @@ pub struct ctxt<'tcx> {
675673 pub freevars : RefCell < FreevarMap > ,
676674 pub tcache : RefCell < DefIdMap < TypeScheme < ' tcx > > > ,
677675 pub rcache : RefCell < FnvHashMap < creader_cache_key , Ty < ' tcx > > > ,
678- pub short_names_cache : RefCell < FnvHashMap < Ty < ' tcx > , String > > ,
679676 pub tc_cache : RefCell < FnvHashMap < Ty < ' tcx > , TypeContents > > ,
680677 pub ast_ty_to_ty_cache : RefCell < NodeMap < Ty < ' tcx > > > ,
681678 pub enum_var_cache : RefCell < DefIdMap < Rc < Vec < Rc < VariantInfo < ' tcx > > > > > > ,
@@ -2741,7 +2738,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
27412738 def_map : def_map,
27422739 node_types : RefCell :: new ( FnvHashMap ( ) ) ,
27432740 item_substs : RefCell :: new ( NodeMap ( ) ) ,
2744- impl_trait_refs : RefCell :: new ( NodeMap ( ) ) ,
2741+ impl_trait_refs : RefCell :: new ( DefIdMap ( ) ) ,
27452742 trait_defs : RefCell :: new ( DefIdMap ( ) ) ,
27462743 predicates : RefCell :: new ( DefIdMap ( ) ) ,
27472744 super_predicates : RefCell :: new ( DefIdMap ( ) ) ,
@@ -2750,14 +2747,12 @@ pub fn mk_ctxt<'tcx>(s: Session,
27502747 freevars : freevars,
27512748 tcache : RefCell :: new ( DefIdMap ( ) ) ,
27522749 rcache : RefCell :: new ( FnvHashMap ( ) ) ,
2753- short_names_cache : RefCell :: new ( FnvHashMap ( ) ) ,
27542750 tc_cache : RefCell :: new ( FnvHashMap ( ) ) ,
27552751 ast_ty_to_ty_cache : RefCell :: new ( NodeMap ( ) ) ,
27562752 enum_var_cache : RefCell :: new ( DefIdMap ( ) ) ,
27572753 impl_or_trait_items : RefCell :: new ( DefIdMap ( ) ) ,
27582754 trait_item_def_ids : RefCell :: new ( DefIdMap ( ) ) ,
27592755 trait_items_cache : RefCell :: new ( DefIdMap ( ) ) ,
2760- impl_trait_cache : RefCell :: new ( DefIdMap ( ) ) ,
27612756 ty_param_defs : RefCell :: new ( NodeMap ( ) ) ,
27622757 adjustments : RefCell :: new ( NodeMap ( ) ) ,
27632758 normalized_cache : RefCell :: new ( FnvHashMap ( ) ) ,
@@ -4464,16 +4459,6 @@ pub fn named_element_ty<'tcx>(cx: &ctxt<'tcx>,
44644459 }
44654460}
44664461
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-
44774462pub fn node_id_to_type < ' tcx > ( cx : & ctxt < ' tcx > , id : ast:: NodeId ) -> Ty < ' tcx > {
44784463 match node_id_to_type_opt ( cx, id) {
44794464 Some ( ty) => ty,
@@ -5268,12 +5253,12 @@ pub fn associated_consts<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
52685253/// the future).
52695254fn lookup_locally_or_in_crate_store < V , F > ( descr : & str ,
52705255 def_id : ast:: DefId ,
5271- map : & mut DefIdMap < V > ,
5256+ map : & RefCell < DefIdMap < V > > ,
52725257 load_external : F ) -> V where
52735258 V : Clone ,
52745259 F : FnOnce ( ) -> V ,
52755260{
5276- match map. get ( & def_id) . cloned ( ) {
5261+ match map. borrow ( ) . get ( & def_id) . cloned ( ) {
52775262 Some ( v) => { return v; }
52785263 None => { }
52795264 }
@@ -5282,7 +5267,7 @@ fn lookup_locally_or_in_crate_store<V, F>(descr: &str,
52825267 panic ! ( "No def'n found for {:?} in tcx.{}" , def_id, descr) ;
52835268 }
52845269 let v = load_external ( ) ;
5285- map. insert ( def_id, v. clone ( ) ) ;
5270+ map. borrow_mut ( ) . insert ( def_id, v. clone ( ) ) ;
52865271 v
52875272}
52885273
@@ -5348,13 +5333,9 @@ pub fn custom_coerce_unsized_kind<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId)
53485333
53495334pub fn impl_or_trait_item < ' tcx > ( cx : & ctxt < ' tcx > , id : ast:: DefId )
53505335 -> 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) )
53585339}
53595340
53605341/// Returns the parameter index that the given associated type corresponds to.
@@ -5881,37 +5862,35 @@ pub fn lookup_item_type<'tcx>(cx: &ctxt<'tcx>,
58815862 did : ast:: DefId )
58825863 -> TypeScheme < ' tcx > {
58835864 lookup_locally_or_in_crate_store (
5884- "tcache" , did, & mut * cx. tcache . borrow_mut ( ) ,
5865+ "tcache" , did, & cx. tcache ,
58855866 || csearch:: get_type ( cx, did) )
58865867}
58875868
58885869/// Given the did of a trait, returns its canonical trait ref.
58895870pub fn lookup_trait_def < ' tcx > ( cx : & ctxt < ' tcx > , did : ast:: DefId )
58905871 -> & ' 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+ )
58955876}
58965877
58975878/// Given the did of an item, returns its full set of predicates.
58985879pub fn lookup_predicates < ' tcx > ( cx : & ctxt < ' tcx > , did : ast:: DefId )
58995880 -> GenericPredicates < ' tcx >
59005881{
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) )
59055885}
59065886
59075887/// Given the did of a trait, returns its superpredicates.
59085888pub fn lookup_super_predicates < ' tcx > ( cx : & ctxt < ' tcx > , did : ast:: DefId )
59095889 -> GenericPredicates < ' tcx >
59105890{
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) )
59155894}
59165895
59175896pub fn predicates < ' tcx > (
@@ -6281,7 +6260,7 @@ pub fn required_region_bounds<'tcx>(tcx: &ctxt<'tcx>,
62816260
62826261pub fn item_variances ( tcx : & ctxt , item_id : ast:: DefId ) -> Rc < ItemVariances > {
62836262 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 ,
62856264 || Rc :: new ( csearch:: get_item_variances ( & tcx. sess . cstore , item_id) ) )
62866265}
62876266
0 commit comments