@@ -76,23 +76,38 @@ impl<'a> DefCollector<'a> {
76
76
fn visit_async_fn (
77
77
& mut self ,
78
78
id : NodeId ,
79
- async_node_id : NodeId ,
80
- return_impl_trait_id : NodeId ,
81
79
name : Name ,
82
80
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 ,
84
85
) {
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
+
85
94
// For async functions, we need to create their inner defs inside of a
86
95
// closure to match their desugared representation.
87
96
let fn_def_data = DefPathData :: ValueNs ( name. as_interned_str ( ) ) ;
88
97
let fn_def = self . create_def ( id, fn_def_data, ITEM_LIKE_SPACE , span) ;
89
98
return self . with_parent ( fn_def, |this| {
90
99
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,
92
105
DefPathData :: ClosureExpr ,
93
106
REGULAR_SPACE ,
94
107
span) ;
95
- this. with_parent ( closure_def, visit_fn)
108
+ this. with_parent ( closure_def, |this| {
109
+ visit:: walk_block ( this, body) ;
110
+ } )
96
111
} )
97
112
}
98
113
@@ -122,17 +137,20 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
122
137
ItemKind :: Mod ( ..) if i. ident == keywords:: Invalid . ident ( ) => {
123
138
return visit:: walk_item ( self , i) ;
124
139
}
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
+ ) => {
129
146
return self . visit_async_fn (
130
147
i. id ,
131
- closure_id,
132
- return_impl_trait_id,
133
148
i. ident . name ,
134
149
i. span ,
135
- |this| visit:: walk_item ( this, i)
150
+ header,
151
+ generics,
152
+ decl,
153
+ body,
136
154
)
137
155
}
138
156
ItemKind :: Mod ( ..) => DefPathData :: Module ( i. ident . as_interned_str ( ) ) ,
@@ -233,18 +251,17 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
233
251
fn visit_impl_item ( & mut self , ii : & ' a ImplItem ) {
234
252
let def_data = match ii. node {
235
253
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) => {
241
257
return self . visit_async_fn (
242
258
ii. id ,
243
- closure_id,
244
- return_impl_trait_id,
245
259
ii. ident . name ,
246
260
ii. span ,
247
- |this| visit:: walk_impl_item ( this, ii)
261
+ header,
262
+ & ii. generics ,
263
+ decl,
264
+ body,
248
265
)
249
266
}
250
267
ImplItemKind :: Method ( ..) | ImplItemKind :: Const ( ..) =>
0 commit comments