@@ -670,7 +670,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
670
670
let params = arena_vec ! [ self ; param] ;
671
671
672
672
let body = self . lower_body ( move |this| {
673
- this. coroutine_kind = Some ( hir:: CoroutineKind :: Async ( async_coroutine_source) ) ;
673
+ this. coroutine_kind = Some ( hir:: CoroutineKind :: Desugared (
674
+ hir:: CoroutineDesugaring :: Async ,
675
+ async_coroutine_source,
676
+ ) ) ;
674
677
675
678
let old_ctx = this. task_context ;
676
679
this. task_context = Some ( task_context_hid) ;
@@ -724,7 +727,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
724
727
} ) ;
725
728
726
729
let body = self . lower_body ( move |this| {
727
- this. coroutine_kind = Some ( hir:: CoroutineKind :: Gen ( coroutine_source) ) ;
730
+ this. coroutine_kind = Some ( hir:: CoroutineKind :: Desugared (
731
+ hir:: CoroutineDesugaring :: Gen ,
732
+ coroutine_source,
733
+ ) ) ;
728
734
729
735
let res = body ( this) ;
730
736
( & [ ] , res)
@@ -802,7 +808,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
802
808
let params = arena_vec ! [ self ; param] ;
803
809
804
810
let body = self . lower_body ( move |this| {
805
- this. coroutine_kind = Some ( hir:: CoroutineKind :: AsyncGen ( async_coroutine_source) ) ;
811
+ this. coroutine_kind = Some ( hir:: CoroutineKind :: Desugared (
812
+ hir:: CoroutineDesugaring :: AsyncGen ,
813
+ async_coroutine_source,
814
+ ) ) ;
806
815
807
816
let old_ctx = this. task_context ;
808
817
this. task_context = Some ( task_context_hid) ;
@@ -888,9 +897,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
888
897
let full_span = expr. span . to ( await_kw_span) ;
889
898
890
899
let is_async_gen = match self . coroutine_kind {
891
- Some ( hir:: CoroutineKind :: Async ( _) ) => false ,
892
- Some ( hir:: CoroutineKind :: AsyncGen ( _) ) => true ,
893
- Some ( hir:: CoroutineKind :: Coroutine ) | Some ( hir:: CoroutineKind :: Gen ( _) ) | None => {
900
+ Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Async , _) ) => false ,
901
+ Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: AsyncGen , _) ) => true ,
902
+ Some ( hir:: CoroutineKind :: Coroutine )
903
+ | Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Gen , _) )
904
+ | None => {
894
905
return hir:: ExprKind :: Err ( self . tcx . sess . emit_err ( AwaitOnlyInAsyncFnAndBlocks {
895
906
await_kw_span,
896
907
item_span : self . current_item ,
@@ -1123,9 +1134,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1123
1134
Some ( movability)
1124
1135
}
1125
1136
Some (
1126
- hir:: CoroutineKind :: Gen ( _)
1127
- | hir:: CoroutineKind :: Async ( _)
1128
- | hir:: CoroutineKind :: AsyncGen ( _) ,
1137
+ hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: Gen , _)
1138
+ | hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: Async , _)
1139
+ | hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: AsyncGen , _) ,
1129
1140
) => {
1130
1141
panic ! ( "non-`async`/`gen` closure body turned `async`/`gen` during lowering" ) ;
1131
1142
}
@@ -1638,9 +1649,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1638
1649
1639
1650
fn lower_expr_yield ( & mut self , span : Span , opt_expr : Option < & Expr > ) -> hir:: ExprKind < ' hir > {
1640
1651
let is_async_gen = match self . coroutine_kind {
1641
- Some ( hir:: CoroutineKind :: Gen ( _) ) => false ,
1642
- Some ( hir:: CoroutineKind :: AsyncGen ( _) ) => true ,
1643
- Some ( hir:: CoroutineKind :: Async ( _) ) => {
1652
+ Some ( hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: Gen , _) ) => false ,
1653
+ Some ( hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: AsyncGen , _) ) => true ,
1654
+ Some ( hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: Async , _) ) => {
1644
1655
return hir:: ExprKind :: Err (
1645
1656
self . tcx . sess . emit_err ( AsyncCoroutinesNotSupported { span } ) ,
1646
1657
) ;
0 commit comments