@@ -89,9 +89,14 @@ impl LoweringContext<'_> {
89
89
hir:: MatchSource :: Normal ,
90
90
) ,
91
91
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
+ )
95
100
}
96
101
ExprKind :: Await ( ref expr) => self . lower_expr_await ( e. span , expr) ,
97
102
ExprKind :: Closure (
@@ -457,6 +462,7 @@ impl LoweringContext<'_> {
457
462
closure_node_id : NodeId ,
458
463
ret_ty : Option < AstP < Ty > > ,
459
464
span : Span ,
465
+ async_gen_kind : hir:: AsyncGeneratorKind ,
460
466
body : impl FnOnce ( & mut LoweringContext < ' _ > ) -> hir:: Expr ,
461
467
) -> hir:: ExprKind {
462
468
let capture_clause = self . lower_capture_clause ( capture_clause) ;
@@ -470,7 +476,7 @@ impl LoweringContext<'_> {
470
476
} ;
471
477
let decl = self . lower_fn_decl ( & ast_decl, None , /* impl trait allowed */ false , None ) ;
472
478
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 ) ) ;
474
480
body ( this)
475
481
} ) ;
476
482
@@ -522,7 +528,7 @@ impl LoweringContext<'_> {
522
528
/// ```
523
529
fn lower_expr_await ( & mut self , await_span : Span , expr : & Expr ) -> hir:: ExprKind {
524
530
match self . generator_kind {
525
- Some ( hir:: GeneratorKind :: Async ) => { } ,
531
+ Some ( hir:: GeneratorKind :: Async ( _ ) ) => { } ,
526
532
Some ( hir:: GeneratorKind :: Gen ) |
527
533
None => {
528
534
let mut err = struct_span_err ! (
@@ -727,7 +733,7 @@ impl LoweringContext<'_> {
727
733
Movability :: Static => hir:: GeneratorMovability :: Static ,
728
734
} )
729
735
} ,
730
- Some ( hir:: GeneratorKind :: Async ) => {
736
+ Some ( hir:: GeneratorKind :: Async ( _ ) ) => {
731
737
bug ! ( "non-`async` closure body turned `async` during lowering" ) ;
732
738
} ,
733
739
None => {
@@ -786,10 +792,12 @@ impl LoweringContext<'_> {
786
792
None
787
793
} ;
788
794
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) ) ,
793
801
) ;
794
802
this. expr ( fn_decl_span, async_body, ThinVec :: new ( ) )
795
803
} ) ;
@@ -1005,7 +1013,7 @@ impl LoweringContext<'_> {
1005
1013
fn lower_expr_yield ( & mut self , span : Span , opt_expr : Option < & Expr > ) -> hir:: ExprKind {
1006
1014
match self . generator_kind {
1007
1015
Some ( hir:: GeneratorKind :: Gen ) => { } ,
1008
- Some ( hir:: GeneratorKind :: Async ) => {
1016
+ Some ( hir:: GeneratorKind :: Async ( _ ) ) => {
1009
1017
span_err ! (
1010
1018
self . sess,
1011
1019
span,
0 commit comments