1313// FIXME: (@jroesch) @eddyb should remove this when he renames ctxt
1414#![ allow( non_camel_case_types) ]
1515
16- use dep_graph:: { DepGraph , DepNode , DepTrackingMap } ;
16+ use dep_graph:: { DepGraph , DepTrackingMap } ;
1717use front:: map as ast_map;
1818use session:: Session ;
1919use lint;
@@ -256,9 +256,8 @@ pub struct ctxt<'tcx> {
256256 pub trait_item_def_ids : RefCell < DepTrackingMap < maps:: TraitItemDefIds < ' tcx > > > ,
257257
258258 /// A cache for the trait_items() routine; note that the routine
259- /// itself pushes the `TraitItems` dependency node. This cache is
260- /// "encapsulated" and thus does not need to be itself tracked.
261- trait_items_cache : RefCell < DefIdMap < Rc < Vec < ty:: ImplOrTraitItem < ' tcx > > > > > ,
259+ /// itself pushes the `TraitItems` dependency node.
260+ trait_items_cache : RefCell < DepTrackingMap < maps:: TraitItems < ' tcx > > > ,
262261
263262 pub impl_trait_refs : RefCell < DepTrackingMap < maps:: ImplTraitRefs < ' tcx > > > ,
264263 pub trait_defs : RefCell < DepTrackingMap < maps:: TraitDefs < ' tcx > > > ,
@@ -371,9 +370,7 @@ pub struct ctxt<'tcx> {
371370 pub fulfilled_predicates : RefCell < traits:: FulfilledPredicates < ' tcx > > ,
372371
373372 /// Caches the representation hints for struct definitions.
374- ///
375- /// This is encapsulated by the `ReprHints` task and hence is not tracked.
376- repr_hint_cache : RefCell < DefIdMap < Rc < Vec < attr:: ReprAttr > > > > ,
373+ repr_hint_cache : RefCell < DepTrackingMap < maps:: ReprHints < ' tcx > > > ,
377374
378375 /// Maps Expr NodeId's to their constant qualification.
379376 pub const_qualif_map : RefCell < NodeMap < middle:: check_const:: ConstQualif > > ,
@@ -544,7 +541,7 @@ impl<'tcx> ctxt<'tcx> {
544541 ast_ty_to_ty_cache : RefCell :: new ( NodeMap ( ) ) ,
545542 impl_or_trait_items : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
546543 trait_item_def_ids : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
547- trait_items_cache : RefCell :: new ( DefIdMap ( ) ) ,
544+ trait_items_cache : RefCell :: new ( DepTrackingMap :: new ( dep_graph . clone ( ) ) ) ,
548545 ty_param_defs : RefCell :: new ( NodeMap ( ) ) ,
549546 normalized_cache : RefCell :: new ( FnvHashMap ( ) ) ,
550547 lang_items : lang_items,
@@ -561,7 +558,7 @@ impl<'tcx> ctxt<'tcx> {
561558 stability : RefCell :: new ( stability) ,
562559 selection_cache : traits:: SelectionCache :: new ( ) ,
563560 evaluation_cache : traits:: EvaluationCache :: new ( ) ,
564- repr_hint_cache : RefCell :: new ( DefIdMap ( ) ) ,
561+ repr_hint_cache : RefCell :: new ( DepTrackingMap :: new ( dep_graph . clone ( ) ) ) ,
565562 const_qualif_map : RefCell :: new ( NodeMap ( ) ) ,
566563 custom_coerce_unsized_kinds : RefCell :: new ( DefIdMap ( ) ) ,
567564 cast_kinds : RefCell :: new ( NodeMap ( ) ) ,
@@ -1032,28 +1029,16 @@ impl<'tcx> ctxt<'tcx> {
10321029 }
10331030
10341031 pub fn trait_items ( & self , trait_did : DefId ) -> Rc < Vec < ty:: ImplOrTraitItem < ' tcx > > > {
1035- // since this is cached, pushing a dep-node for the
1036- // computation yields the correct dependencies.
1037- let _task = self . dep_graph . in_task ( DepNode :: TraitItems ( trait_did) ) ;
1038-
1039- let mut trait_items = self . trait_items_cache . borrow_mut ( ) ;
1040- match trait_items. get ( & trait_did) . cloned ( ) {
1041- Some ( trait_items) => trait_items,
1042- None => {
1043- let def_ids = self . trait_item_def_ids ( trait_did) ;
1044- let items: Rc < Vec < _ > > =
1045- Rc :: new ( def_ids. iter ( )
1046- . map ( |d| self . impl_or_trait_item ( d. def_id ( ) ) )
1047- . collect ( ) ) ;
1048- trait_items. insert ( trait_did, items. clone ( ) ) ;
1049- items
1050- }
1051- }
1032+ self . trait_items_cache . memoize ( trait_did, || {
1033+ let def_ids = self . trait_item_def_ids ( trait_did) ;
1034+ Rc :: new ( def_ids. iter ( )
1035+ . map ( |d| self . impl_or_trait_item ( d. def_id ( ) ) )
1036+ . collect ( ) )
1037+ } )
10521038 }
10531039
10541040 /// Obtain the representation annotation for a struct definition.
10551041 pub fn lookup_repr_hints ( & self , did : DefId ) -> Rc < Vec < attr:: ReprAttr > > {
1056- let _task = self . dep_graph . in_task ( DepNode :: ReprHints ( did) ) ;
10571042 self . repr_hint_cache . memoize ( did, || {
10581043 Rc :: new ( if did. is_local ( ) {
10591044 self . get_attrs ( did) . iter ( ) . flat_map ( |meta| {
0 commit comments