@@ -157,11 +157,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
157
157
fn visit_fn ( & mut self , fn_kind : FnKind < ' a > , span : Span , _: NodeId ) {
158
158
if let FnKind :: Fn ( _, _, sig, _, generics, body) = fn_kind {
159
159
match sig. header . coroutine_kind {
160
- Some (
161
- CoroutineKind :: Async { closure_id, .. }
162
- | CoroutineKind :: Gen { closure_id, .. }
163
- | CoroutineKind :: AsyncGen { closure_id, .. } ,
164
- ) => {
160
+ Some ( coroutine_kind) => {
165
161
self . visit_generics ( generics) ;
166
162
167
163
// For async functions, we need to create their inner defs inside of a
@@ -176,8 +172,12 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
176
172
// then the closure_def will never be used, and we should avoid generating a
177
173
// def-id for it.
178
174
if let Some ( body) = body {
179
- let closure_def =
180
- self . create_def ( closure_id, kw:: Empty , DefKind :: Closure , span) ;
175
+ let closure_def = self . create_def (
176
+ coroutine_kind. closure_id ( ) ,
177
+ kw:: Empty ,
178
+ DefKind :: Closure ,
179
+ span,
180
+ ) ;
181
181
self . with_parent ( closure_def, |this| this. visit_block ( body) ) ;
182
182
}
183
183
return ;
@@ -289,11 +289,12 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
289
289
// we must create two defs.
290
290
let closure_def = self . create_def ( expr. id , kw:: Empty , DefKind :: Closure , expr. span ) ;
291
291
match closure. coroutine_kind {
292
- Some (
293
- CoroutineKind :: Async { closure_id, .. }
294
- | CoroutineKind :: Gen { closure_id, .. }
295
- | CoroutineKind :: AsyncGen { closure_id, .. } ,
296
- ) => self . create_def ( closure_id, kw:: Empty , DefKind :: Closure , expr. span ) ,
292
+ Some ( coroutine_kind) => self . create_def (
293
+ coroutine_kind. closure_id ( ) ,
294
+ kw:: Empty ,
295
+ DefKind :: Closure ,
296
+ expr. span ,
297
+ ) ,
297
298
None => closure_def,
298
299
}
299
300
}
0 commit comments