@@ -14,7 +14,7 @@ use rustc_target::spec::abi;
14
14
use syntax:: ast:: * ;
15
15
use syntax:: attr;
16
16
use syntax:: node_id:: NodeMap ;
17
- use syntax:: visit:: { self , Visitor } ;
17
+ use syntax:: visit:: { self , AssocCtxt , Visitor } ;
18
18
19
19
use log:: debug;
20
20
use smallvec:: { smallvec, SmallVec } ;
@@ -81,25 +81,23 @@ impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
81
81
}
82
82
}
83
83
84
- fn visit_trait_item ( & mut self , item : & ' a AssocItem ) {
85
- self . lctx . with_hir_id_owner ( item. id , |lctx| {
86
- let hir_item = lctx. lower_trait_item ( item) ;
87
- let id = hir:: TraitItemId { hir_id : hir_item. hir_id } ;
88
- lctx. trait_items . insert ( id, hir_item) ;
89
- lctx. modules . get_mut ( & lctx. current_module ) . unwrap ( ) . trait_items . insert ( id) ;
84
+ fn visit_assoc_item ( & mut self , item : & ' a AssocItem , ctxt : AssocCtxt ) {
85
+ self . lctx . with_hir_id_owner ( item. id , |lctx| match ctxt {
86
+ AssocCtxt :: Trait => {
87
+ let hir_item = lctx. lower_trait_item ( item) ;
88
+ let id = hir:: TraitItemId { hir_id : hir_item. hir_id } ;
89
+ lctx. trait_items . insert ( id, hir_item) ;
90
+ lctx. modules . get_mut ( & lctx. current_module ) . unwrap ( ) . trait_items . insert ( id) ;
91
+ }
92
+ AssocCtxt :: Impl => {
93
+ let hir_item = lctx. lower_impl_item ( item) ;
94
+ let id = hir:: ImplItemId { hir_id : hir_item. hir_id } ;
95
+ lctx. impl_items . insert ( id, hir_item) ;
96
+ lctx. modules . get_mut ( & lctx. current_module ) . unwrap ( ) . impl_items . insert ( id) ;
97
+ }
90
98
} ) ;
91
99
92
- visit:: walk_trait_item ( self , item) ;
93
- }
94
-
95
- fn visit_impl_item ( & mut self , item : & ' a AssocItem ) {
96
- self . lctx . with_hir_id_owner ( item. id , |lctx| {
97
- let hir_item = lctx. lower_impl_item ( item) ;
98
- let id = hir:: ImplItemId { hir_id : hir_item. hir_id } ;
99
- lctx. impl_items . insert ( id, hir_item) ;
100
- lctx. modules . get_mut ( & lctx. current_module ) . unwrap ( ) . impl_items . insert ( id) ;
101
- } ) ;
102
- visit:: walk_impl_item ( self , item) ;
100
+ visit:: walk_assoc_item ( self , item, ctxt) ;
103
101
}
104
102
}
105
103
@@ -299,20 +297,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
299
297
// `impl Future<Output = T>` here because lower_body
300
298
// only cares about the input argument patterns in the function
301
299
// declaration (decl), not the return types.
300
+ let asyncness = header. asyncness . node ;
302
301
let body_id =
303
- this. lower_maybe_async_body ( span, & decl, header . asyncness . node , Some ( body) ) ;
302
+ this. lower_maybe_async_body ( span, & decl, asyncness, body. as_deref ( ) ) ;
304
303
305
304
let ( generics, decl) = this. add_in_band_defs (
306
305
generics,
307
306
fn_def_id,
308
307
AnonymousLifetimeMode :: PassThrough ,
309
308
|this, idty| {
310
- this. lower_fn_decl (
311
- & decl,
312
- Some ( ( fn_def_id, idty) ) ,
313
- true ,
314
- header. asyncness . node . opt_return_id ( ) ,
315
- )
309
+ let ret_id = asyncness. opt_return_id ( ) ;
310
+ this. lower_fn_decl ( & decl, Some ( ( fn_def_id, idty) ) , true , ret_id)
316
311
} ,
317
312
) ;
318
313
let sig = hir:: FnSig { decl, header : this. lower_fn_header ( header) } ;
@@ -658,7 +653,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
658
653
ident : i. ident ,
659
654
attrs : self . lower_attrs ( & i. attrs ) ,
660
655
kind : match i. kind {
661
- ForeignItemKind :: Fn ( ref fdec, ref generics) => {
656
+ ForeignItemKind :: Fn ( ref sig, ref generics, _) => {
657
+ let fdec = & sig. decl ;
662
658
let ( generics, ( fn_dec, fn_args) ) = self . add_in_band_defs (
663
659
generics,
664
660
def_id,
0 commit comments