@@ -5,7 +5,7 @@ use crate::hir::{GenericParam, ItemLocalId};
5
5
use crate :: hir:: { GenericParamKind , LifetimeParamKind } ;
6
6
use crate :: ty;
7
7
8
- use crate :: util:: nodemap:: { FxHashMap , FxHashSet , HirIdMap , HirIdSet } ;
8
+ use crate :: util:: nodemap:: { FxHashMap , FxHashSet } ;
9
9
use rustc_macros:: HashStable ;
10
10
11
11
/// The origin of a named lifetime definition.
@@ -68,60 +68,19 @@ pub type ObjectLifetimeDefault = Set1<Region>;
68
68
69
69
/// Maps the id of each lifetime reference to the lifetime decl
70
70
/// that it corresponds to.
71
- #[ derive( HashStable ) ]
71
+ #[ derive( Default , HashStable ) ]
72
72
pub struct ResolveLifetimes {
73
- defs : FxHashMap < LocalDefId , FxHashMap < ItemLocalId , Region > > ,
74
- late_bound : FxHashMap < LocalDefId , FxHashSet < ItemLocalId > > ,
75
- object_lifetime_defaults :
76
- FxHashMap < LocalDefId , FxHashMap < ItemLocalId , Vec < ObjectLifetimeDefault > > > ,
77
- }
73
+ /// Maps from every use of a named (not anonymous) lifetime to a
74
+ /// `Region` describing how that region is bound
75
+ pub defs : FxHashMap < LocalDefId , FxHashMap < ItemLocalId , Region > > ,
78
76
79
- impl ResolveLifetimes {
80
- pub fn new (
81
- defs : HirIdMap < Region > ,
82
- late_bound : HirIdSet ,
83
- object_lifetime_defaults : HirIdMap < Vec < ObjectLifetimeDefault > > ,
84
- ) -> Self {
85
- let defs = {
86
- let mut map = FxHashMap :: < _ , FxHashMap < _ , _ > > :: default ( ) ;
87
- for ( hir_id, v) in defs {
88
- let map = map. entry ( hir_id. owner_local_def_id ( ) ) . or_default ( ) ;
89
- map. insert ( hir_id. local_id , v) ;
90
- }
91
- map
92
- } ;
93
- let late_bound = {
94
- let mut map = FxHashMap :: < _ , FxHashSet < _ > > :: default ( ) ;
95
- for hir_id in late_bound {
96
- let map = map. entry ( hir_id. owner_local_def_id ( ) ) . or_default ( ) ;
97
- map. insert ( hir_id. local_id ) ;
98
- }
99
- map
100
- } ;
101
- let object_lifetime_defaults = {
102
- let mut map = FxHashMap :: < _ , FxHashMap < _ , _ > > :: default ( ) ;
103
- for ( hir_id, v) in object_lifetime_defaults {
104
- let map = map. entry ( hir_id. owner_local_def_id ( ) ) . or_default ( ) ;
105
- map. insert ( hir_id. local_id , v) ;
106
- }
107
- map
108
- } ;
109
-
110
- Self { defs, late_bound, object_lifetime_defaults }
111
- }
77
+ /// Set of lifetime def ids that are late-bound; a region can
78
+ /// be late-bound if (a) it does NOT appear in a where-clause and
79
+ /// (b) it DOES appear in the arguments.
80
+ pub late_bound : FxHashMap < LocalDefId , FxHashSet < ItemLocalId > > ,
112
81
113
- pub fn named_region_map ( & self , id : & LocalDefId ) -> Option < & FxHashMap < ItemLocalId , Region > > {
114
- self . defs . get ( id)
115
- }
116
-
117
- pub fn is_late_bound_map ( & self , id : & LocalDefId ) -> Option < & FxHashSet < ItemLocalId > > {
118
- self . late_bound . get ( id)
119
- }
120
-
121
- pub fn object_lifetime_defaults_map (
122
- & self ,
123
- id : & LocalDefId ,
124
- ) -> Option < & FxHashMap < ItemLocalId , Vec < ObjectLifetimeDefault > > > {
125
- self . object_lifetime_defaults . get ( id)
126
- }
82
+ /// For each type and trait definition, maps type parameters
83
+ /// to the trait object lifetime defaults computed from them.
84
+ pub object_lifetime_defaults :
85
+ FxHashMap < LocalDefId , FxHashMap < ItemLocalId , Vec < ObjectLifetimeDefault > > > ,
127
86
}
0 commit comments