@@ -136,39 +136,9 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
136
136
137
137
fn lower_assoc_item ( & mut self , item : & AssocItem , ctxt : AssocCtxt ) {
138
138
let def_id = self . resolver . node_id_to_def_id [ & item. id ] ;
139
-
140
139
let parent_id = self . tcx . local_parent ( def_id) ;
141
140
let parent_hir = self . lower_node ( parent_id) . unwrap ( ) ;
142
- self . with_lctx ( item. id , |lctx| {
143
- // Evaluate with the lifetimes in `params` in-scope.
144
- // This is used to track which lifetimes have already been defined,
145
- // and which need to be replicated when lowering an async fn.
146
-
147
- match parent_hir. node ( ) . expect_item ( ) . kind {
148
- hir:: ItemKind :: Impl ( impl_) => {
149
- lctx. is_in_trait_impl = impl_. of_trait . is_some ( ) ;
150
- }
151
- hir:: ItemKind :: Trait ( _, _, generics, _, _) if lctx. tcx . features ( ) . effects => {
152
- lctx. host_param_id = generics
153
- . params
154
- . iter ( )
155
- . find ( |param| {
156
- parent_hir
157
- . attrs
158
- . get ( param. hir_id . local_id )
159
- . iter ( )
160
- . any ( |attr| attr. has_name ( sym:: rustc_host) )
161
- } )
162
- . map ( |param| param. def_id ) ;
163
- }
164
- _ => { }
165
- }
166
-
167
- match ctxt {
168
- AssocCtxt :: Trait => hir:: OwnerNode :: TraitItem ( lctx. lower_trait_item ( item) ) ,
169
- AssocCtxt :: Impl => hir:: OwnerNode :: ImplItem ( lctx. lower_impl_item ( item) ) ,
170
- }
171
- } )
141
+ self . with_lctx ( item. id , |lctx| lctx. lower_assoc_item ( item, ctxt, parent_hir) )
172
142
}
173
143
174
144
fn lower_foreign_item ( & mut self , item : & ForeignItem ) {
@@ -609,6 +579,42 @@ impl<'hir> LoweringContext<'_, 'hir> {
609
579
}
610
580
}
611
581
582
+ fn lower_assoc_item (
583
+ & mut self ,
584
+ item : & AssocItem ,
585
+ ctxt : AssocCtxt ,
586
+ parent_hir : & ' hir hir:: OwnerInfo < ' hir > ,
587
+ ) -> hir:: OwnerNode < ' hir > {
588
+ // Evaluate with the lifetimes in `params` in-scope.
589
+ // This is used to track which lifetimes have already been defined,
590
+ // and which need to be replicated when lowering an async fn.
591
+
592
+ match parent_hir. node ( ) . expect_item ( ) . kind {
593
+ hir:: ItemKind :: Impl ( impl_) => {
594
+ self . is_in_trait_impl = impl_. of_trait . is_some ( ) ;
595
+ }
596
+ hir:: ItemKind :: Trait ( _, _, generics, _, _) if self . tcx . features ( ) . effects => {
597
+ self . host_param_id = generics
598
+ . params
599
+ . iter ( )
600
+ . find ( |param| {
601
+ parent_hir
602
+ . attrs
603
+ . get ( param. hir_id . local_id )
604
+ . iter ( )
605
+ . any ( |attr| attr. has_name ( sym:: rustc_host) )
606
+ } )
607
+ . map ( |param| param. def_id ) ;
608
+ }
609
+ _ => { }
610
+ }
611
+
612
+ match ctxt {
613
+ AssocCtxt :: Trait => hir:: OwnerNode :: TraitItem ( self . lower_trait_item ( item) ) ,
614
+ AssocCtxt :: Impl => hir:: OwnerNode :: ImplItem ( self . lower_impl_item ( item) ) ,
615
+ }
616
+ }
617
+
612
618
fn lower_foreign_item ( & mut self , i : & ForeignItem ) -> & ' hir hir:: ForeignItem < ' hir > {
613
619
let hir_id = self . lower_node_id ( i. id ) ;
614
620
let owner_id = hir_id. expect_owner ( ) ;
0 commit comments