@@ -157,11 +157,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
157157    fn  visit_fn ( & mut  self ,  fn_kind :  FnKind < ' a > ,  span :  Span ,  _:  NodeId )  { 
158158        if  let  FnKind :: Fn ( _,  _,  sig,  _,  generics,  body)  = fn_kind { 
159159            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)  => { 
165161                    self . visit_generics ( generics) ; 
166162
167163                    // 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> {
176172                    // then the closure_def will never be used, and we should avoid generating a 
177173                    // def-id for it. 
178174                    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+                         ) ; 
181181                        self . with_parent ( closure_def,  |this| this. visit_block ( body) ) ; 
182182                    } 
183183                    return ; 
@@ -289,11 +289,12 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
289289                // we must create two defs. 
290290                let  closure_def = self . create_def ( expr. id ,  kw:: Empty ,  DefKind :: Closure ,  expr. span ) ; 
291291                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+                     ) , 
297298                    None  => closure_def, 
298299                } 
299300            } 
0 commit comments