@@ -31,7 +31,7 @@ use rustc_ast as ast;
3131use rustc_ast:: expand:: typetree:: { FncTree , Kind , Type , TypeTree } ;
3232use rustc_ast:: node_id:: NodeMap ;
3333pub use rustc_ast_ir:: { Movability , Mutability , try_visit} ;
34- use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
34+ use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
3535use rustc_data_structures:: intern:: Interned ;
3636use rustc_data_structures:: stable_hash:: { StableHash , StableHashCtxt , StableHasher } ;
3737use rustc_data_structures:: steal:: Steal ;
@@ -205,7 +205,15 @@ pub struct ResolverGlobalCtxt {
205205
206206#[ derive( Debug ) ]
207207pub struct PerOwnerResolverData {
208- pub node_id_to_def_id : NodeMap < LocalDefId > ,
208+ pub node_id_to_def_id : NodeMap < LocalDefId > = Default :: default ( ) ,
209+ /// Whether lifetime elision was successful.
210+ pub lifetime_elision_allowed : bool = false,
211+ /// Resolutions for labels.
212+ /// Maps from NodeId of the break/continue expression to the NodeId of their corresponding blocks or loops.
213+ pub label_res_map : NodeMap < ast:: NodeId > = Default :: default ( ) ,
214+ /// Resolutions for lifetimes.
215+ pub lifetimes_res_map : NodeMap < LifetimeRes > = Default :: default ( ) ,
216+
209217 /// The id of the owner
210218 pub id : ast:: NodeId ,
211219 /// The `DefId` of the owner, can't be found in `node_id_to_def_id`.
@@ -214,7 +222,17 @@ pub struct PerOwnerResolverData {
214222
215223impl PerOwnerResolverData {
216224 pub fn new ( id : ast:: NodeId , def_id : LocalDefId ) -> PerOwnerResolverData {
217- PerOwnerResolverData { node_id_to_def_id : Default :: default ( ) , id, def_id }
225+ PerOwnerResolverData { id, def_id, .. }
226+ }
227+
228+ /// Obtains resolution for a label with the given `NodeId`.
229+ pub fn get_label_res ( & self , id : ast:: NodeId ) -> Option < ast:: NodeId > {
230+ self . label_res_map . get ( & id) . copied ( )
231+ }
232+
233+ /// Obtains resolution for a lifetime with the given `NodeId`.
234+ pub fn get_lifetime_res ( & self , id : ast:: NodeId ) -> Option < LifetimeRes > {
235+ self . lifetimes_res_map . get ( & id) . copied ( )
218236 }
219237}
220238
@@ -226,10 +244,6 @@ pub struct ResolverAstLowering<'tcx> {
226244 pub partial_res_map : NodeMap < hir:: def:: PartialRes > ,
227245 /// Resolutions for import nodes, which have multiple resolutions in different namespaces.
228246 pub import_res_map : NodeMap < hir:: def:: PerNS < Option < Res < ast:: NodeId > > > > ,
229- /// Resolutions for labels (node IDs of their corresponding blocks or loops).
230- pub label_res_map : NodeMap < ast:: NodeId > ,
231- /// Resolutions for lifetimes.
232- pub lifetimes_res_map : NodeMap < LifetimeRes > ,
233247 /// Lifetime parameters that lowering will have to introduce.
234248 pub extra_lifetime_params_map : NodeMap < Vec < ( Ident , ast:: NodeId , MissingLifetimeKind ) > > ,
235249
@@ -238,8 +252,6 @@ pub struct ResolverAstLowering<'tcx> {
238252 pub owners : NodeMap < PerOwnerResolverData > ,
239253
240254 pub trait_map : NodeMap < & ' tcx [ hir:: TraitCandidate < ' tcx > ] > ,
241- /// List functions and methods for which lifetime elision was successful.
242- pub lifetime_elision_allowed : FxHashSet < ast:: NodeId > ,
243255
244256 /// Lints that were emitted by the resolver and early lints.
245257 pub lint_buffer : Steal < LintBuffer > ,
0 commit comments