@@ -14,7 +14,7 @@ use rustc_target::spec::abi;
1414use syntax:: ast:: * ;
1515use syntax:: attr;
1616use syntax:: node_id:: NodeMap ;
17- use syntax:: visit:: { self , Visitor } ;
17+ use syntax:: visit:: { self , AssocCtxt , Visitor } ;
1818
1919use log:: debug;
2020use smallvec:: { smallvec, SmallVec } ;
@@ -81,25 +81,23 @@ impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
8181 }
8282 }
8383
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+ }
9098 } ) ;
9199
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) ;
103101 }
104102}
105103
@@ -299,20 +297,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
299297 // `impl Future<Output = T>` here because lower_body
300298 // only cares about the input argument patterns in the function
301299 // declaration (decl), not the return types.
300+ let asyncness = header. asyncness . node ;
302301 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 ( ) ) ;
304303
305304 let ( generics, decl) = this. add_in_band_defs (
306305 generics,
307306 fn_def_id,
308307 AnonymousLifetimeMode :: PassThrough ,
309308 |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)
316311 } ,
317312 ) ;
318313 let sig = hir:: FnSig { decl, header : this. lower_fn_header ( header) } ;
@@ -658,7 +653,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
658653 ident : i. ident ,
659654 attrs : self . lower_attrs ( & i. attrs ) ,
660655 kind : match i. kind {
661- ForeignItemKind :: Fn ( ref fdec, ref generics) => {
656+ ForeignItemKind :: Fn ( ref sig, ref generics, _) => {
657+ let fdec = & sig. decl ;
662658 let ( generics, ( fn_dec, fn_args) ) = self . add_in_band_defs (
663659 generics,
664660 def_id,
0 commit comments