@@ -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) ;
@@ -877,9 +886,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
877
886
let full_span = expr. span . to ( await_kw_span) ;
878
887
879
888
let is_async_gen = match self . coroutine_kind {
880
- Some ( hir:: CoroutineKind :: Async ( _) ) => false ,
881
- Some ( hir:: CoroutineKind :: AsyncGen ( _) ) => true ,
882
- Some ( hir:: CoroutineKind :: Coroutine ) | Some ( hir:: CoroutineKind :: Gen ( _) ) | None => {
889
+ Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Async , _) ) => false ,
890
+ Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: AsyncGen , _) ) => true ,
891
+ Some ( hir:: CoroutineKind :: Coroutine )
892
+ | Some ( hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Gen , _) )
893
+ | None => {
883
894
return hir:: ExprKind :: Err ( self . tcx . sess . emit_err ( AwaitOnlyInAsyncFnAndBlocks {
884
895
await_kw_span,
885
896
item_span : self . current_item ,
@@ -1097,9 +1108,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1097
1108
Some ( movability)
1098
1109
}
1099
1110
Some (
1100
- hir:: CoroutineKind :: Gen ( _)
1101
- | hir:: CoroutineKind :: Async ( _)
1102
- | hir:: CoroutineKind :: AsyncGen ( _) ,
1111
+ hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: Gen , _)
1112
+ | hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: Async , _)
1113
+ | hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: AsyncGen , _) ,
1103
1114
) => {
1104
1115
panic ! ( "non-`async`/`gen` closure body turned `async`/`gen` during lowering" ) ;
1105
1116
}
@@ -1612,9 +1623,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1612
1623
1613
1624
fn lower_expr_yield ( & mut self , span : Span , opt_expr : Option < & Expr > ) -> hir:: ExprKind < ' hir > {
1614
1625
let is_async_gen = match self . coroutine_kind {
1615
- Some ( hir:: CoroutineKind :: Gen ( _) ) => false ,
1616
- Some ( hir:: CoroutineKind :: AsyncGen ( _) ) => true ,
1617
- Some ( hir:: CoroutineKind :: Async ( _) ) => {
1626
+ Some ( hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: Gen , _) ) => false ,
1627
+ Some ( hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: AsyncGen , _) ) => true ,
1628
+ Some ( hir:: CoroutineKind :: Desugared ( hir :: CoroutineDesugaring :: Async , _) ) => {
1618
1629
return hir:: ExprKind :: Err (
1619
1630
self . tcx . sess . emit_err ( AsyncCoroutinesNotSupported { span } ) ,
1620
1631
) ;
0 commit comments