@@ -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 (
@@ -457,6 +462,7 @@ impl LoweringContext<'_> {
457462 closure_node_id : NodeId ,
458463 ret_ty : Option < AstP < Ty > > ,
459464 span : Span ,
465+ async_gen_kind : hir:: AsyncGeneratorKind ,
460466 body : impl FnOnce ( & mut LoweringContext < ' _ > ) -> hir:: Expr ,
461467 ) -> hir:: ExprKind {
462468 let capture_clause = self . lower_capture_clause ( capture_clause) ;
@@ -470,7 +476,7 @@ impl LoweringContext<'_> {
470476 } ;
471477 let decl = self . lower_fn_decl ( & ast_decl, None , /* impl trait allowed */ false , None ) ;
472478 let body_id = self . lower_fn_body ( & ast_decl, |this| {
473- this. generator_kind = Some ( hir:: GeneratorKind :: Async ) ;
479+ this. generator_kind = Some ( hir:: GeneratorKind :: Async ( async_gen_kind ) ) ;
474480 body ( this)
475481 } ) ;
476482
@@ -522,7 +528,7 @@ impl LoweringContext<'_> {
522528 /// ```
523529 fn lower_expr_await ( & mut self , await_span : Span , expr : & Expr ) -> hir:: ExprKind {
524530 match self . generator_kind {
525- Some ( hir:: GeneratorKind :: Async ) => { } ,
531+ Some ( hir:: GeneratorKind :: Async ( _ ) ) => { } ,
526532 Some ( hir:: GeneratorKind :: Gen ) |
527533 None => {
528534 let mut err = struct_span_err ! (
@@ -727,7 +733,7 @@ impl LoweringContext<'_> {
727733 Movability :: Static => hir:: GeneratorMovability :: Static ,
728734 } )
729735 } ,
730- Some ( hir:: GeneratorKind :: Async ) => {
736+ Some ( hir:: GeneratorKind :: Async ( _ ) ) => {
731737 bug ! ( "non-`async` closure body turned `async` during lowering" ) ;
732738 } ,
733739 None => {
@@ -786,10 +792,12 @@ impl LoweringContext<'_> {
786792 None
787793 } ;
788794 let async_body = this. make_async_expr (
789- capture_clause, closure_id, async_ret_ty, body. span ,
790- |this| {
791- this. with_new_scopes ( |this| this. lower_expr ( body) )
792- }
795+ capture_clause,
796+ closure_id,
797+ async_ret_ty,
798+ body. span ,
799+ hir:: AsyncGeneratorKind :: Closure ,
800+ |this| this. with_new_scopes ( |this| this. lower_expr ( body) ) ,
793801 ) ;
794802 this. expr ( fn_decl_span, async_body, ThinVec :: new ( ) )
795803 } ) ;
@@ -1005,7 +1013,7 @@ impl LoweringContext<'_> {
10051013 fn lower_expr_yield ( & mut self , span : Span , opt_expr : Option < & Expr > ) -> hir:: ExprKind {
10061014 match self . generator_kind {
10071015 Some ( hir:: GeneratorKind :: Gen ) => { } ,
1008- Some ( hir:: GeneratorKind :: Async ) => {
1016+ Some ( hir:: GeneratorKind :: Async ( _ ) ) => {
10091017 span_err ! (
10101018 self . sess,
10111019 span,
0 commit comments