13
13
// FIXME: (@jroesch) @eddyb should remove this when he renames ctxt
14
14
#![ allow( non_camel_case_types) ]
15
15
16
- use dep_graph:: { DepGraph , DepNode , DepTrackingMap } ;
16
+ use dep_graph:: { DepGraph , DepTrackingMap } ;
17
17
use front:: map as ast_map;
18
18
use session:: Session ;
19
19
use lint;
@@ -256,9 +256,8 @@ pub struct ctxt<'tcx> {
256
256
pub trait_item_def_ids : RefCell < DepTrackingMap < maps:: TraitItemDefIds < ' tcx > > > ,
257
257
258
258
/// 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 > > > ,
262
261
263
262
pub impl_trait_refs : RefCell < DepTrackingMap < maps:: ImplTraitRefs < ' tcx > > > ,
264
263
pub trait_defs : RefCell < DepTrackingMap < maps:: TraitDefs < ' tcx > > > ,
@@ -371,9 +370,7 @@ pub struct ctxt<'tcx> {
371
370
pub fulfilled_predicates : RefCell < traits:: FulfilledPredicates < ' tcx > > ,
372
371
373
372
/// 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 > > > ,
377
374
378
375
/// Maps Expr NodeId's to their constant qualification.
379
376
pub const_qualif_map : RefCell < NodeMap < middle:: check_const:: ConstQualif > > ,
@@ -544,7 +541,7 @@ impl<'tcx> ctxt<'tcx> {
544
541
ast_ty_to_ty_cache : RefCell :: new ( NodeMap ( ) ) ,
545
542
impl_or_trait_items : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
546
543
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 ( ) ) ) ,
548
545
ty_param_defs : RefCell :: new ( NodeMap ( ) ) ,
549
546
normalized_cache : RefCell :: new ( FnvHashMap ( ) ) ,
550
547
lang_items : lang_items,
@@ -561,7 +558,7 @@ impl<'tcx> ctxt<'tcx> {
561
558
stability : RefCell :: new ( stability) ,
562
559
selection_cache : traits:: SelectionCache :: new ( ) ,
563
560
evaluation_cache : traits:: EvaluationCache :: new ( ) ,
564
- repr_hint_cache : RefCell :: new ( DefIdMap ( ) ) ,
561
+ repr_hint_cache : RefCell :: new ( DepTrackingMap :: new ( dep_graph . clone ( ) ) ) ,
565
562
const_qualif_map : RefCell :: new ( NodeMap ( ) ) ,
566
563
custom_coerce_unsized_kinds : RefCell :: new ( DefIdMap ( ) ) ,
567
564
cast_kinds : RefCell :: new ( NodeMap ( ) ) ,
@@ -1032,28 +1029,16 @@ impl<'tcx> ctxt<'tcx> {
1032
1029
}
1033
1030
1034
1031
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
+ } )
1052
1038
}
1053
1039
1054
1040
/// Obtain the representation annotation for a struct definition.
1055
1041
pub fn lookup_repr_hints ( & self , did : DefId ) -> Rc < Vec < attr:: ReprAttr > > {
1056
- let _task = self . dep_graph . in_task ( DepNode :: ReprHints ( did) ) ;
1057
1042
self . repr_hint_cache . memoize ( did, || {
1058
1043
Rc :: new ( if did. is_local ( ) {
1059
1044
self . get_attrs ( did) . iter ( ) . flat_map ( |meta| {
0 commit comments