@@ -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 ;
@@ -206,7 +206,15 @@ pub struct ResolverGlobalCtxt {
206206
207207#[ derive( Debug ) ]
208208pub struct PerOwnerResolverData {
209- pub node_id_to_def_id : NodeMap < LocalDefId > ,
209+ pub node_id_to_def_id : NodeMap < LocalDefId > = Default :: default ( ) ,
210+ /// Whether lifetime elision was successful.
211+ pub lifetime_elision_allowed : bool = false,
212+ /// Resolutions for labels.
213+ /// Maps from NodeId of the break/continue expression to the NodeId of their corresponding blocks or loops.
214+ pub label_res_map : NodeMap < ast:: NodeId > = Default :: default ( ) ,
215+ /// Resolutions for lifetimes.
216+ pub lifetimes_res_map : NodeMap < LifetimeRes > = Default :: default ( ) ,
217+
210218 /// The id of the owner
211219 pub id : ast:: NodeId ,
212220 /// The `DefId` of the owner, can't be found in `node_id_to_def_id`.
@@ -215,7 +223,17 @@ pub struct PerOwnerResolverData {
215223
216224impl PerOwnerResolverData {
217225 pub fn new ( id : ast:: NodeId , def_id : LocalDefId ) -> PerOwnerResolverData {
218- PerOwnerResolverData { node_id_to_def_id : Default :: default ( ) , id, def_id }
226+ PerOwnerResolverData { id, def_id, .. }
227+ }
228+
229+ /// Obtains resolution for a label with the given `NodeId`.
230+ pub fn get_label_res ( & self , id : ast:: NodeId ) -> Option < ast:: NodeId > {
231+ self . label_res_map . get ( & id) . copied ( )
232+ }
233+
234+ /// Obtains resolution for a lifetime with the given `NodeId`.
235+ pub fn get_lifetime_res ( & self , id : ast:: NodeId ) -> Option < LifetimeRes > {
236+ self . lifetimes_res_map . get ( & id) . copied ( )
219237 }
220238}
221239
@@ -227,10 +245,6 @@ pub struct ResolverAstLowering<'tcx> {
227245 pub partial_res_map : NodeMap < hir:: def:: PartialRes > ,
228246 /// Resolutions for import nodes, which have multiple resolutions in different namespaces.
229247 pub import_res_map : NodeMap < hir:: def:: PerNS < Option < Res < ast:: NodeId > > > > ,
230- /// Resolutions for labels (node IDs of their corresponding blocks or loops).
231- pub label_res_map : NodeMap < ast:: NodeId > ,
232- /// Resolutions for lifetimes.
233- pub lifetimes_res_map : NodeMap < LifetimeRes > ,
234248 /// Lifetime parameters that lowering will have to introduce.
235249 pub extra_lifetime_params_map : NodeMap < Vec < ( Ident , ast:: NodeId , LifetimeRes ) > > ,
236250
@@ -239,8 +253,6 @@ pub struct ResolverAstLowering<'tcx> {
239253 pub owners : NodeMap < PerOwnerResolverData > ,
240254
241255 pub trait_map : NodeMap < & ' tcx [ hir:: TraitCandidate < ' tcx > ] > ,
242- /// List functions and methods for which lifetime elision was successful.
243- pub lifetime_elision_allowed : FxHashSet < ast:: NodeId > ,
244256
245257 /// Lints that were emitted by the resolver and early lints.
246258 pub lint_buffer : Steal < LintBuffer > ,
0 commit comments