@@ -89,9 +89,14 @@ impl LoweringContext<'_> {
8989 hir:: MatchSource :: Normal ,
9090 ) ,
9191 ExprKind :: Async ( capture_clause, closure_node_id, ref block) => {
92- self . make_async_expr ( capture_clause, closure_node_id, None , block. span , |this| {
93- this. with_new_scopes ( |this| this. lower_block_expr ( block) )
94- } )
92+ self . make_async_expr (
93+ capture_clause,
94+ closure_node_id,
95+ None ,
96+ block. span ,
97+ hir:: AsyncGeneratorKind :: Block ,
98+ |this| this. with_new_scopes ( |this| this. lower_block_expr ( block) ) ,
99+ )
95100 }
96101 ExprKind :: Await ( ref expr) => self . lower_expr_await ( e. span , expr) ,
97102 ExprKind :: Closure (
@@ -440,6 +445,7 @@ impl LoweringContext<'_> {
440445 closure_node_id : NodeId ,
441446 ret_ty : Option < AstP < Ty > > ,
442447 span : Span ,
448+ async_gen_kind : hir:: AsyncGeneratorKind ,
443449 body : impl FnOnce ( & mut LoweringContext < ' _ > ) -> hir:: Expr ,
444450 ) -> hir:: ExprKind {
445451 let capture_clause = self . lower_capture_clause ( capture_clause) ;
@@ -453,7 +459,7 @@ impl LoweringContext<'_> {
453459 } ;
454460 let decl = self . lower_fn_decl ( & ast_decl, None , /* impl trait allowed */ false , None ) ;
455461 let body_id = self . lower_fn_body ( & ast_decl, |this| {
456- this. generator_kind = Some ( hir:: GeneratorKind :: Async ) ;
462+ this. generator_kind = Some ( hir:: GeneratorKind :: Async ( async_gen_kind ) ) ;
457463 body ( this)
458464 } ) ;
459465
@@ -505,7 +511,7 @@ impl LoweringContext<'_> {
505511 /// ```
506512 fn lower_expr_await ( & mut self , await_span : Span , expr : & Expr ) -> hir:: ExprKind {
507513 match self . generator_kind {
508- Some ( hir:: GeneratorKind :: Async ) => { } ,
514+ Some ( hir:: GeneratorKind :: Async ( _ ) ) => { } ,
509515 Some ( hir:: GeneratorKind :: Gen ) |
510516 None => {
511517 let mut err = struct_span_err ! (
@@ -710,7 +716,7 @@ impl LoweringContext<'_> {
710716 Movability :: Static => hir:: GeneratorMovability :: Static ,
711717 } )
712718 } ,
713- Some ( hir:: GeneratorKind :: Async ) => {
719+ Some ( hir:: GeneratorKind :: Async ( _ ) ) => {
714720 bug ! ( "non-`async` closure body turned `async` during lowering" ) ;
715721 } ,
716722 None => {
@@ -769,7 +775,7 @@ impl LoweringContext<'_> {
769775 None
770776 } ;
771777 let async_body = this. make_async_expr (
772- capture_clause, closure_id, async_ret_ty, body. span ,
778+ capture_clause, closure_id, async_ret_ty, body. span , hir :: AsyncGeneratorKind :: Closure ,
773779 |this| {
774780 this. with_new_scopes ( |this| this. lower_expr ( body) )
775781 }
@@ -988,7 +994,7 @@ impl LoweringContext<'_> {
988994 fn lower_expr_yield ( & mut self , span : Span , opt_expr : Option < & Expr > ) -> hir:: ExprKind {
989995 match self . generator_kind {
990996 Some ( hir:: GeneratorKind :: Gen ) => { } ,
991- Some ( hir:: GeneratorKind :: Async ) => {
997+ Some ( hir:: GeneratorKind :: Async ( _ ) ) => {
992998 span_err ! (
993999 self . sess,
9941000 span,
0 commit comments