1- use super :: { AstOwner , ImplTraitContext , ImplTraitPosition , ResolverAstLowering } ;
1+ use super :: ResolverAstLoweringExt ;
2+ use super :: { AstOwner , ImplTraitContext , ImplTraitPosition } ;
23use super :: { LoweringContext , ParamMode } ;
34use crate :: { Arena , FnDeclKind } ;
45
@@ -11,8 +12,11 @@ use rustc_errors::struct_span_err;
1112use rustc_hir as hir;
1213use rustc_hir:: def:: { DefKind , Res } ;
1314use rustc_hir:: def_id:: { LocalDefId , CRATE_DEF_ID } ;
15+ use rustc_hir:: definitions:: Definitions ;
1416use rustc_hir:: PredicateOrigin ;
1517use rustc_index:: vec:: { Idx , IndexVec } ;
18+ use rustc_middle:: ty:: { ResolverAstLowering , ResolverOutputs } ;
19+ use rustc_session:: cstore:: CrateStoreDyn ;
1620use rustc_session:: Session ;
1721use rustc_span:: source_map:: DesugaringKind ;
1822use rustc_span:: symbol:: { kw, sym, Ident } ;
@@ -24,7 +28,10 @@ use std::iter;
2428
2529pub ( super ) struct ItemLowerer < ' a , ' hir > {
2630 pub ( super ) sess : & ' a Session ,
27- pub ( super ) resolver : & ' a mut dyn ResolverAstLowering ,
31+ pub ( super ) definitions : & ' a mut Definitions ,
32+ pub ( super ) cstore : & ' a CrateStoreDyn ,
33+ pub ( super ) resolutions : & ' a ResolverOutputs ,
34+ pub ( super ) resolver : & ' a mut ResolverAstLowering ,
2835 pub ( super ) arena : & ' hir Arena < ' hir > ,
2936 pub ( super ) ast_index : & ' a IndexVec < LocalDefId , AstOwner < ' a > > ,
3037 pub ( super ) owners : & ' a mut IndexVec < LocalDefId , hir:: MaybeOwner < & ' hir hir:: OwnerInfo < ' hir > > > ,
@@ -59,6 +66,9 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
5966 let mut lctx = LoweringContext {
6067 // Pseudo-globals.
6168 sess : & self . sess ,
69+ definitions : self . definitions ,
70+ cstore : self . cstore ,
71+ resolutions : self . resolutions ,
6272 resolver : self . resolver ,
6373 arena : self . arena ,
6474
@@ -118,8 +128,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
118128
119129 #[ instrument( level = "debug" , skip( self , c) ) ]
120130 fn lower_crate ( & mut self , c : & Crate ) {
121- debug_assert_eq ! ( self . resolver. local_def_id( CRATE_NODE_ID ) , CRATE_DEF_ID ) ;
122-
131+ debug_assert_eq ! ( self . resolver. node_id_to_def_id[ & CRATE_NODE_ID ] , CRATE_DEF_ID ) ;
123132 self . with_lctx ( CRATE_NODE_ID , |lctx| {
124133 let module = lctx. lower_mod ( & c. items , & c. spans ) ;
125134 lctx. lower_attrs ( hir:: CRATE_HIR_ID , & c. attrs ) ;
@@ -133,10 +142,10 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
133142 }
134143
135144 fn lower_assoc_item ( & mut self , item : & AssocItem , ctxt : AssocCtxt ) {
136- let def_id = self . resolver . local_def_id ( item. id ) ;
145+ let def_id = self . resolver . node_id_to_def_id [ & item. id ] ;
137146
138147 let parent_id = {
139- let parent = self . resolver . definitions ( ) . def_key ( def_id) . parent ;
148+ let parent = self . definitions . def_key ( def_id) . parent ;
140149 let local_def_index = parent. unwrap ( ) ;
141150 LocalDefId { local_def_index }
142151 } ;
@@ -177,7 +186,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
177186 }
178187
179188 pub ( super ) fn lower_item_ref ( & mut self , i : & Item ) -> SmallVec < [ hir:: ItemId ; 1 ] > {
180- let mut node_ids = smallvec ! [ hir:: ItemId { def_id: self . resolver . local_def_id( i. id) } ] ;
189+ let mut node_ids = smallvec ! [ hir:: ItemId { def_id: self . local_def_id( i. id) } ] ;
181190 if let ItemKind :: Use ( ref use_tree) = & i. kind {
182191 self . lower_item_id_use_tree ( use_tree, i. id , & mut node_ids) ;
183192 }
@@ -193,7 +202,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
193202 match tree. kind {
194203 UseTreeKind :: Nested ( ref nested_vec) => {
195204 for & ( ref nested, id) in nested_vec {
196- vec. push ( hir:: ItemId { def_id : self . resolver . local_def_id ( id) } ) ;
205+ vec. push ( hir:: ItemId { def_id : self . local_def_id ( id) } ) ;
197206 self . lower_item_id_use_tree ( nested, id, vec) ;
198207 }
199208 }
@@ -202,7 +211,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
202211 for ( _, & id) in
203212 iter:: zip ( self . expect_full_res_from_use ( base_id) . skip ( 1 ) , & [ id1, id2] )
204213 {
205- vec. push ( hir:: ItemId { def_id : self . resolver . local_def_id ( id) } ) ;
214+ vec. push ( hir:: ItemId { def_id : self . local_def_id ( id) } ) ;
206215 }
207216 }
208217 }
@@ -467,7 +476,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
467476 }
468477 ItemKind :: MacroDef ( MacroDef { ref body, macro_rules } ) => {
469478 let body = P ( self . lower_mac_args ( body) ) ;
470- let macro_kind = self . resolver . decl_macro_kind ( self . resolver . local_def_id ( id) ) ;
479+ let macro_kind = self . resolver . decl_macro_kind ( self . local_def_id ( id) ) ;
471480 hir:: ItemKind :: Macro ( ast:: MacroDef { body, macro_rules } , macro_kind)
472481 }
473482 ItemKind :: MacCall ( ..) => {
@@ -527,7 +536,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
527536 // Essentially a single `use` which imports two names is desugared into
528537 // two imports.
529538 for new_node_id in [ id1, id2] {
530- let new_id = self . resolver . local_def_id ( new_node_id) ;
539+ let new_id = self . local_def_id ( new_node_id) ;
531540 let Some ( res) = resolutions. next ( ) else {
532541 // Associate an HirId to both ids even if there is no resolution.
533542 let _old = self . children . insert (
@@ -540,7 +549,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
540549 let ident = * ident;
541550 let mut path = path. clone ( ) ;
542551 for seg in & mut path. segments {
543- seg. id = self . resolver . next_node_id ( ) ;
552+ seg. id = self . next_node_id ( ) ;
544553 }
545554 let span = path. span ;
546555
@@ -603,13 +612,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
603612
604613 // Add all the nested `PathListItem`s to the HIR.
605614 for & ( ref use_tree, id) in trees {
606- let new_hir_id = self . resolver . local_def_id ( id) ;
615+ let new_hir_id = self . local_def_id ( id) ;
607616
608617 let mut prefix = prefix. clone ( ) ;
609618
610619 // Give the segments new node-ids since they are being cloned.
611620 for seg in & mut prefix. segments {
612- seg. id = self . resolver . next_node_id ( ) ;
621+ seg. id = self . next_node_id ( ) ;
613622 }
614623
615624 // Each `use` import is an item and thus are owners of the
@@ -683,7 +692,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
683692
684693 fn lower_foreign_item_ref ( & mut self , i : & ForeignItem ) -> hir:: ForeignItemRef {
685694 hir:: ForeignItemRef {
686- id : hir:: ForeignItemId { def_id : self . resolver . local_def_id ( i. id ) } ,
695+ id : hir:: ForeignItemId { def_id : self . local_def_id ( i. id ) } ,
687696 ident : self . lower_ident ( i. ident ) ,
688697 span : self . lower_span ( i. span ) ,
689698 }
@@ -839,7 +848,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
839848 }
840849 AssocItemKind :: MacCall ( ..) => unimplemented ! ( ) ,
841850 } ;
842- let id = hir:: TraitItemId { def_id : self . resolver . local_def_id ( i. id ) } ;
851+ let id = hir:: TraitItemId { def_id : self . local_def_id ( i. id ) } ;
843852 let defaultness = hir:: Defaultness :: Default { has_value : has_default } ;
844853 hir:: TraitItemRef {
845854 id,
@@ -919,7 +928,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
919928 let has_value = true ;
920929 let ( defaultness, _) = self . lower_defaultness ( i. kind . defaultness ( ) , has_value) ;
921930 hir:: ImplItemRef {
922- id : hir:: ImplItemId { def_id : self . resolver . local_def_id ( i. id ) } ,
931+ id : hir:: ImplItemId { def_id : self . local_def_id ( i. id ) } ,
923932 ident : self . lower_ident ( i. ident ) ,
924933 span : self . lower_span ( i. span ) ,
925934 defaultness,
@@ -1331,7 +1340,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13311340 generics
13321341 . params
13331342 . iter ( )
1334- . any ( |p| def_id == self . resolver . local_def_id ( p. id ) . to_def_id ( ) )
1343+ . any ( |p| def_id == self . local_def_id ( p. id ) . to_def_id ( ) )
13351344 }
13361345 // Either the `bounded_ty` is not a plain type parameter, or
13371346 // it's not found in the generic type parameters list.
@@ -1435,7 +1444,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14351444 match kind {
14361445 GenericParamKind :: Const { .. } => None ,
14371446 GenericParamKind :: Type { .. } => {
1438- let def_id = self . resolver . local_def_id ( id) . to_def_id ( ) ;
1447+ let def_id = self . local_def_id ( id) . to_def_id ( ) ;
14391448 let ty_path = self . arena . alloc ( hir:: Path {
14401449 span : param_span,
14411450 res : Res :: Def ( DefKind :: TyParam , def_id) ,
@@ -1458,7 +1467,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14581467 let res = self . resolver . get_lifetime_res ( id) . unwrap_or_else ( || {
14591468 panic ! ( "Missing resolution for lifetime {:?} at {:?}" , id, ident. span)
14601469 } ) ;
1461- let lt_id = self . resolver . next_node_id ( ) ;
1470+ let lt_id = self . next_node_id ( ) ;
14621471 let lifetime = self . new_named_lifetime_with_res ( lt_id, ident_span, ident, res) ;
14631472 Some ( hir:: WherePredicate :: RegionPredicate ( hir:: WhereRegionPredicate {
14641473 lifetime,
0 commit comments