11use std:: mem;
2- use std:: sync:: Arc ;
32
43use rustc_abi:: ExternAbi ;
54use rustc_ast:: visit:: AssocCtxt ;
65use rustc_ast:: * ;
76use rustc_data_structures:: fx:: FxIndexMap ;
8- use rustc_data_structures:: steal:: Steal ;
97use rustc_errors:: { E0570 , ErrorGuaranteed , struct_span_code_err} ;
108use rustc_hir:: attrs:: { AttributeKind , EiiImplResolution } ;
119use rustc_hir:: def:: { DefKind , PerNS , Res } ;
12- use rustc_hir:: def_id:: { CRATE_DEF_ID , LocalDefId , LocalDefIdMap } ;
13- use rustc_hir:: definitions:: PerParentDisambiguatorState ;
10+ use rustc_hir:: def_id:: { CRATE_DEF_ID , LocalDefId } ;
1411use rustc_hir:: {
1512 self as hir, HirId , ImplItemImplKind , LifetimeSource , PredicateOrigin , Target , find_attr,
1613} ;
1714use rustc_index:: { IndexSlice , IndexVec } ;
1815use rustc_middle:: span_bug;
19- use rustc_middle:: ty:: TyCtxt ;
16+ use rustc_middle:: ty:: { ResolverAstLowering , TyCtxt } ;
2017use rustc_span:: def_id:: DefId ;
2118use rustc_span:: edit_distance:: find_best_match_for_name;
2219use rustc_span:: { DUMMY_SP , DesugaringKind , Ident , Span , Symbol , kw, sym} ;
@@ -51,21 +48,11 @@ impl<'hir> Owners<'_, 'hir> {
5148 }
5249}
5350
54- /// Default disambiguators are used during default lowering, when we lower
55- /// AST owners in a loop we can use the whole map, in contrast delayed lowering
56- /// lowers each AST owner separately, so we use readonly disambiguators map
57- /// with `Steal`s to get disambiguators.
58- pub ( super ) enum Disambiguators {
59- Default ( LocalDefIdMap < PerParentDisambiguatorState > ) ,
60- Delayed ( Arc < LocalDefIdMap < Steal < PerParentDisambiguatorState > > > ) ,
61- }
62-
63- pub ( super ) struct ItemLowerer < ' a , ' hir , R > {
51+ pub ( super ) struct ItemLowerer < ' a , ' hir > {
6452 pub ( super ) tcx : TyCtxt < ' hir > ,
65- pub ( super ) resolver : & ' a mut R ,
53+ pub ( super ) resolver : & ' a ResolverAstLowering < ' hir > ,
6654 pub ( super ) ast_index : & ' a IndexSlice < LocalDefId , AstOwner < ' a > > ,
6755 pub ( super ) owners : Owners < ' a , ' hir > ,
68- pub ( super ) disambiguators : & ' a mut Disambiguators ,
6956}
7057
7158/// When we have a ty alias we *may* have two where clauses. To give the best diagnostics, we set the span
@@ -87,13 +74,13 @@ fn add_ty_alias_where_clause(
8774 if before. 0 || !after. 0 { before } else { after } ;
8875}
8976
90- impl < ' hir , R : ResolverAstLoweringExt < ' hir > > ItemLowerer < ' _ , ' hir , R > {
77+ impl < ' hir > ItemLowerer < ' _ , ' hir > {
9178 fn with_lctx (
9279 & mut self ,
9380 owner : NodeId ,
94- f : impl FnOnce ( & mut LoweringContext < ' _ , ' hir , R > ) -> hir:: OwnerNode < ' hir > ,
81+ f : impl for < ' a > FnOnce ( & mut LoweringContext < ' a , ' hir > ) -> hir:: OwnerNode < ' hir > ,
9582 ) {
96- let mut lctx = LoweringContext :: new ( self . tcx , self . resolver , self . disambiguators ) ;
83+ let mut lctx = LoweringContext :: new ( self . tcx , self . resolver ) ;
9784 lctx. with_hir_id_owner ( owner, |lctx| f ( lctx) ) ;
9885
9986 for ( def_id, info) in lctx. children {
@@ -135,7 +122,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> ItemLowerer<'_, 'hir, R> {
135122 }
136123}
137124
138- impl < ' hir , R : ResolverAstLoweringExt < ' hir > > LoweringContext < ' _ , ' hir , R > {
125+ impl < ' hir > LoweringContext < ' _ , ' hir > {
139126 pub ( super ) fn lower_mod (
140127 & mut self ,
141128 items : & [ Box < Item > ] ,
@@ -648,7 +635,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
648635 }
649636
650637 fn lower_path_simple_eii ( & mut self , id : NodeId , path : & Path ) -> Option < DefId > {
651- let res = self . resolver . get_partial_res ( id) ?;
638+ let res = self . get_partial_res ( id) ?;
652639 let Some ( did) = res. expect_full_res ( ) . opt_def_id ( ) else {
653640 self . dcx ( ) . span_delayed_bug ( path. span , "should have errored in resolve" ) ;
654641 return None ;
@@ -1349,7 +1336,6 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
13491336 ImplItemImplKind :: Trait {
13501337 defaultness,
13511338 trait_item_def_id : self
1352- . resolver
13531339 . get_partial_res ( i. id )
13541340 . and_then ( |r| r. expect_full_res ( ) . opt_def_id ( ) )
13551341 . ok_or_else ( || {
@@ -1545,7 +1531,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
15451531 pub ( crate ) fn lower_coroutine_body_with_moved_arguments (
15461532 & mut self ,
15471533 decl : & FnDecl ,
1548- lower_body : impl FnOnce ( & mut LoweringContext < ' _ , ' hir , R > ) -> hir:: Expr < ' hir > ,
1534+ lower_body : impl FnOnce ( & mut LoweringContext < ' _ , ' hir > ) -> hir:: Expr < ' hir > ,
15491535 fn_decl_span : Span ,
15501536 body_span : Span ,
15511537 coroutine_kind : CoroutineKind ,
@@ -1682,7 +1668,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
16821668 parameters. push ( new_parameter) ;
16831669 }
16841670
1685- let mkbody = |this : & mut LoweringContext < ' _ , ' hir , R > | {
1671+ let mkbody = |this : & mut LoweringContext < ' _ , ' hir > | {
16861672 // Create a block from the user's function body:
16871673 let user_body = lower_body ( this) ;
16881674
@@ -1867,7 +1853,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
18671853 let kind = match & r. kind {
18681854 RestrictionKind :: Unrestricted => hir:: RestrictionKind :: Unrestricted ,
18691855 RestrictionKind :: Restricted { path, id, shorthand : _ } => {
1870- let res = self . resolver . get_partial_res ( * id) ;
1856+ let res = self . get_partial_res ( * id) ;
18711857 if let Some ( did) = res. and_then ( |res| res. expect_full_res ( ) . opt_def_id ( ) ) {
18721858 hir:: RestrictionKind :: Restricted ( self . arena . alloc ( hir:: Path {
18731859 res : did,
@@ -1933,7 +1919,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
19331919
19341920 // Introduce extra lifetimes if late resolution tells us to.
19351921 let extra_lifetimes = self . resolver . extra_lifetime_params ( parent_node_id) ;
1936- params. extend ( extra_lifetimes. into_iter ( ) . filter_map ( |( ident, node_id, res) | {
1922+ params. extend ( extra_lifetimes. into_iter ( ) . filter_map ( |& ( ident, node_id, res) | {
19371923 self . lifetime_res_to_generic_param (
19381924 ident,
19391925 node_id,
@@ -1975,7 +1961,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
19751961 return ;
19761962 } ;
19771963 let define_opaque = define_opaque. iter ( ) . filter_map ( |( id, path) | {
1978- let res = self . resolver . get_partial_res ( * id) ;
1964+ let res = self . get_partial_res ( * id) ;
19791965 let Some ( did) = res. and_then ( |res| res. expect_full_res ( ) . opt_def_id ( ) ) else {
19801966 self . dcx ( ) . span_delayed_bug ( path. span , "should have errored in resolve" ) ;
19811967 return None ;
0 commit comments