10
10
11
11
//! type context book-keeping
12
12
13
- use dep_graph:: { DepGraph , DepTrackingMap } ;
13
+ use dep_graph:: DepGraph ;
14
14
use session:: Session ;
15
15
use lint;
16
16
use middle;
@@ -412,44 +412,9 @@ pub struct GlobalCtxt<'tcx> {
412
412
// borrowck. (They are not used during trans, and hence are not
413
413
// serialized or needed for cross-crate fns.)
414
414
free_region_maps : RefCell < NodeMap < FreeRegionMap > > ,
415
- // FIXME: jroesch make this a refcell
416
-
417
- pub tables : RefCell < DepTrackingMap < maps:: TypeckTables < ' tcx > > > ,
418
-
419
- /// Maps from a trait item to the trait item "descriptor"
420
- pub associated_items : RefCell < DepTrackingMap < maps:: AssociatedItems < ' tcx > > > ,
421
-
422
- /// Maps from an impl/trait def-id to a list of the def-ids of its items
423
- pub associated_item_def_ids : RefCell < DepTrackingMap < maps:: AssociatedItemDefIds < ' tcx > > > ,
424
-
425
- pub impl_trait_refs : RefCell < DepTrackingMap < maps:: ImplTraitRefs < ' tcx > > > ,
426
- pub trait_defs : RefCell < DepTrackingMap < maps:: TraitDefs < ' tcx > > > ,
427
- pub adt_defs : RefCell < DepTrackingMap < maps:: AdtDefs < ' tcx > > > ,
428
- pub adt_sized_constraint : RefCell < DepTrackingMap < maps:: AdtSizedConstraint < ' tcx > > > ,
429
-
430
- /// Maps from the def-id of an item (trait/struct/enum/fn) to its
431
- /// associated generics and predicates.
432
- pub generics : RefCell < DepTrackingMap < maps:: Generics < ' tcx > > > ,
433
- pub predicates : RefCell < DepTrackingMap < maps:: Predicates < ' tcx > > > ,
434
-
435
- /// Maps from the def-id of a trait to the list of
436
- /// super-predicates. This is a subset of the full list of
437
- /// predicates. We store these in a separate map because we must
438
- /// evaluate them even during type conversion, often before the
439
- /// full predicates are available (note that supertraits have
440
- /// additional acyclicity requirements).
441
- pub super_predicates : RefCell < DepTrackingMap < maps:: Predicates < ' tcx > > > ,
442
415
443
416
pub hir : hir_map:: Map < ' tcx > ,
444
-
445
- /// Maps from the def-id of a function/method or const/static
446
- /// to its MIR. Mutation is done at an item granularity to
447
- /// allow MIR optimization passes to function and still
448
- /// access cross-crate MIR (e.g. inlining or const eval).
449
- ///
450
- /// Note that cross-crate MIR appears to be always borrowed
451
- /// (in the `RefCell` sense) to prevent accidental mutation.
452
- pub mir_map : RefCell < DepTrackingMap < maps:: Mir < ' tcx > > > ,
417
+ pub maps : maps:: Maps < ' tcx > ,
453
418
454
419
// Records the free variables refrenced by every closure
455
420
// expression. Do not track deps for this, just recompute it from
@@ -458,9 +423,6 @@ pub struct GlobalCtxt<'tcx> {
458
423
459
424
pub maybe_unused_trait_imports : NodeSet ,
460
425
461
- // Records the type of every item.
462
- pub item_types : RefCell < DepTrackingMap < maps:: Types < ' tcx > > > ,
463
-
464
426
// Internal cache for metadata decoding. No need to track deps on this.
465
427
pub rcache : RefCell < FxHashMap < ty:: CReaderCacheKey , Ty < ' tcx > > > ,
466
428
@@ -474,18 +436,9 @@ pub struct GlobalCtxt<'tcx> {
474
436
475
437
pub lang_items : middle:: lang_items:: LanguageItems ,
476
438
477
- /// Maps from def-id of a type or region parameter to its
478
- /// (inferred) variance.
479
- pub item_variance_map : RefCell < DepTrackingMap < maps:: ItemVariances < ' tcx > > > ,
480
-
481
439
/// True if the variance has been computed yet; false otherwise.
482
440
pub variance_computed : Cell < bool > ,
483
441
484
- /// Maps a DefId of a type to a list of its inherent impls.
485
- /// Contains implementations of methods that are inherent to a type.
486
- /// Methods in these implementations don't need to be exported.
487
- pub inherent_impls : RefCell < DepTrackingMap < maps:: InherentImpls < ' tcx > > > ,
488
-
489
442
/// Set of used unsafe nodes (functions or blocks). Unsafe nodes not
490
443
/// present in this set can be warned about.
491
444
pub used_unsafe : RefCell < NodeSet > ,
@@ -495,10 +448,6 @@ pub struct GlobalCtxt<'tcx> {
495
448
/// about.
496
449
pub used_mut_nodes : RefCell < NodeSet > ,
497
450
498
- /// Set of trait imports actually used in the method resolution.
499
- /// This is used for warning unused imports.
500
- pub used_trait_imports : RefCell < DepTrackingMap < maps:: UsedTraitImports < ' tcx > > > ,
501
-
502
451
/// The set of external nominal types whose implementations have been read.
503
452
/// This is used for lazy resolution of methods.
504
453
pub populated_external_types : RefCell < DefIdSet > ,
@@ -507,10 +456,6 @@ pub struct GlobalCtxt<'tcx> {
507
456
/// FIXME(arielb1): why is this separate from populated_external_types?
508
457
pub populated_external_primitive_impls : RefCell < DefIdSet > ,
509
458
510
- /// Results of evaluating monomorphic constants embedded in
511
- /// other items, such as enum variant explicit discriminants.
512
- pub monomorphic_const_eval : RefCell < DepTrackingMap < maps:: MonomorphicConstEval < ' tcx > > > ,
513
-
514
459
/// Maps any item's def-id to its stability index.
515
460
pub stability : RefCell < stability:: Index < ' tcx > > ,
516
461
@@ -529,23 +474,9 @@ pub struct GlobalCtxt<'tcx> {
529
474
/// (i.e., no type or lifetime parameters).
530
475
pub fulfilled_predicates : RefCell < traits:: GlobalFulfilledPredicates < ' tcx > > ,
531
476
532
- /// Caches the representation hints for struct definitions.
533
- repr_hint_cache : RefCell < DepTrackingMap < maps:: ReprHints < ' tcx > > > ,
534
-
535
477
/// Maps Expr NodeId's to `true` iff `&expr` can have 'static lifetime.
536
478
pub rvalue_promotable_to_static : RefCell < NodeMap < bool > > ,
537
479
538
- /// Caches CoerceUnsized kinds for impls on custom types.
539
- pub custom_coerce_unsized_kinds : RefCell < DefIdMap < ty:: adjustment:: CustomCoerceUnsized > > ,
540
-
541
- /// Records the type of each closure. The def ID is the ID of the
542
- /// expression defining the closure.
543
- pub closure_tys : RefCell < DepTrackingMap < maps:: ClosureTypes < ' tcx > > > ,
544
-
545
- /// Records the type of each closure. The def ID is the ID of the
546
- /// expression defining the closure.
547
- pub closure_kinds : RefCell < DepTrackingMap < maps:: ClosureKinds < ' tcx > > > ,
548
-
549
480
/// Maps Fn items to a collection of fragment infos.
550
481
///
551
482
/// The main goal is to identify data (each of which may be moved
@@ -754,46 +685,27 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
754
685
named_region_map : named_region_map,
755
686
region_maps : region_maps,
756
687
free_region_maps : RefCell :: new ( FxHashMap ( ) ) ,
757
- item_variance_map : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
758
688
variance_computed : Cell :: new ( false ) ,
759
689
sess : s,
760
690
trait_map : resolutions. trait_map ,
761
- tables : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
762
- impl_trait_refs : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
763
- trait_defs : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
764
- adt_defs : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
765
- adt_sized_constraint : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
766
- generics : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
767
- predicates : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
768
- super_predicates : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
769
691
fulfilled_predicates : RefCell :: new ( fulfilled_predicates) ,
770
692
hir : hir,
771
- mir_map : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
693
+ maps : maps :: Maps :: new ( dep_graph) ,
772
694
freevars : RefCell :: new ( resolutions. freevars ) ,
773
695
maybe_unused_trait_imports : resolutions. maybe_unused_trait_imports ,
774
- item_types : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
775
696
rcache : RefCell :: new ( FxHashMap ( ) ) ,
776
697
tc_cache : RefCell :: new ( FxHashMap ( ) ) ,
777
- associated_items : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
778
- associated_item_def_ids : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
779
698
normalized_cache : RefCell :: new ( FxHashMap ( ) ) ,
780
699
inhabitedness_cache : RefCell :: new ( FxHashMap ( ) ) ,
781
700
lang_items : lang_items,
782
- inherent_impls : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
783
701
used_unsafe : RefCell :: new ( NodeSet ( ) ) ,
784
702
used_mut_nodes : RefCell :: new ( NodeSet ( ) ) ,
785
- used_trait_imports : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
786
703
populated_external_types : RefCell :: new ( DefIdSet ( ) ) ,
787
704
populated_external_primitive_impls : RefCell :: new ( DefIdSet ( ) ) ,
788
- monomorphic_const_eval : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
789
705
stability : RefCell :: new ( stability) ,
790
706
selection_cache : traits:: SelectionCache :: new ( ) ,
791
707
evaluation_cache : traits:: EvaluationCache :: new ( ) ,
792
- repr_hint_cache : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
793
708
rvalue_promotable_to_static : RefCell :: new ( NodeMap ( ) ) ,
794
- custom_coerce_unsized_kinds : RefCell :: new ( DefIdMap ( ) ) ,
795
- closure_tys : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
796
- closure_kinds : RefCell :: new ( DepTrackingMap :: new ( dep_graph. clone ( ) ) ) ,
797
709
fragment_infos : RefCell :: new ( DefIdMap ( ) ) ,
798
710
crate_name : Symbol :: intern ( crate_name) ,
799
711
data_layout : data_layout,
@@ -1541,7 +1453,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1541
1453
1542
1454
/// Obtain the representation annotation for a struct definition.
1543
1455
pub fn lookup_repr_hints ( self , did : DefId ) -> Rc < Vec < attr:: ReprAttr > > {
1544
- self . repr_hint_cache . memoize ( did, || {
1456
+ self . maps . repr_hints . memoize ( did, || {
1545
1457
Rc :: new ( self . get_attrs ( did) . iter ( ) . flat_map ( |meta| {
1546
1458
attr:: find_repr_attrs ( self . sess . diagnostic ( ) , meta) . into_iter ( )
1547
1459
} ) . collect ( ) )
0 commit comments