@@ -76,23 +76,38 @@ impl<'a> DefCollector<'a> {
7676 fn visit_async_fn (
7777 & mut self ,
7878 id : NodeId ,
79- async_node_id : NodeId ,
80- return_impl_trait_id : NodeId ,
8179 name : Name ,
8280 span : Span ,
83- visit_fn : impl FnOnce ( & mut DefCollector < ' a > )
81+ header : & FnHeader ,
82+ generics : & ' a Generics ,
83+ decl : & ' a FnDecl ,
84+ body : & ' a Block ,
8485 ) {
86+ let ( closure_id, return_impl_trait_id) = match header. asyncness {
87+ IsAsync :: Async {
88+ closure_id,
89+ return_impl_trait_id,
90+ } => ( closure_id, return_impl_trait_id) ,
91+ _ => unreachable ! ( ) ,
92+ } ;
93+
8594 // For async functions, we need to create their inner defs inside of a
8695 // closure to match their desugared representation.
8796 let fn_def_data = DefPathData :: ValueNs ( name. as_interned_str ( ) ) ;
8897 let fn_def = self . create_def ( id, fn_def_data, ITEM_LIKE_SPACE , span) ;
8998 return self . with_parent ( fn_def, |this| {
9099 this. create_def ( return_impl_trait_id, DefPathData :: ImplTrait , REGULAR_SPACE , span) ;
91- let closure_def = this. create_def ( async_node_id,
100+
101+ visit:: walk_generics ( this, generics) ;
102+ visit:: walk_fn_decl ( this, decl) ;
103+
104+ let closure_def = this. create_def ( closure_id,
92105 DefPathData :: ClosureExpr ,
93106 REGULAR_SPACE ,
94107 span) ;
95- this. with_parent ( closure_def, visit_fn)
108+ this. with_parent ( closure_def, |this| {
109+ visit:: walk_block ( this, body) ;
110+ } )
96111 } )
97112 }
98113
@@ -122,17 +137,20 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
122137 ItemKind :: Mod ( ..) if i. ident == keywords:: Invalid . ident ( ) => {
123138 return visit:: walk_item ( self , i) ;
124139 }
125- ItemKind :: Fn ( _, FnHeader { asyncness : IsAsync :: Async {
126- closure_id,
127- return_impl_trait_id,
128- } , .. } , ..) => {
140+ ItemKind :: Fn (
141+ ref decl,
142+ ref header @ FnHeader { asyncness : IsAsync :: Async { .. } , .. } ,
143+ ref generics,
144+ ref body,
145+ ) => {
129146 return self . visit_async_fn (
130147 i. id ,
131- closure_id,
132- return_impl_trait_id,
133148 i. ident . name ,
134149 i. span ,
135- |this| visit:: walk_item ( this, i)
150+ header,
151+ generics,
152+ decl,
153+ body,
136154 )
137155 }
138156 ItemKind :: Mod ( ..) => DefPathData :: Module ( i. ident . as_interned_str ( ) ) ,
@@ -233,18 +251,17 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
233251 fn visit_impl_item ( & mut self , ii : & ' a ImplItem ) {
234252 let def_data = match ii. node {
235253 ImplItemKind :: Method ( MethodSig {
236- header : FnHeader { asyncness : IsAsync :: Async {
237- closure_id,
238- return_impl_trait_id,
239- } , .. } , ..
240- } , ..) => {
254+ header : ref header @ FnHeader { asyncness : IsAsync :: Async { .. } , .. } ,
255+ ref decl,
256+ } , ref body) => {
241257 return self . visit_async_fn (
242258 ii. id ,
243- closure_id,
244- return_impl_trait_id,
245259 ii. ident . name ,
246260 ii. span ,
247- |this| visit:: walk_impl_item ( this, ii)
261+ header,
262+ & ii. generics ,
263+ decl,
264+ body,
248265 )
249266 }
250267 ImplItemKind :: Method ( ..) | ImplItemKind :: Const ( ..) =>
0 commit comments