11use super :: errors:: {
2- AsyncGeneratorsNotSupported , AsyncNonMoveClosureNotSupported , AwaitOnlyInAsyncFnAndBlocks ,
3- BaseExpressionDoubleDot , ClosureCannotBeStatic , FunctionalRecordUpdateDestructuringAssignment ,
4- GeneratorTooManyParameters , InclusiveRangeWithNoEnd , NotSupportedForLifetimeBinderAsyncClosure ,
5- UnderscoreExprLhsAssign ,
2+ AsyncCoroutinesNotSupported , AsyncNonMoveClosureNotSupported , AwaitOnlyInAsyncFnAndBlocks ,
3+ BaseExpressionDoubleDot , ClosureCannotBeStatic , CoroutineTooManyParameters ,
4+ FunctionalRecordUpdateDestructuringAssignment , InclusiveRangeWithNoEnd ,
5+ NotSupportedForLifetimeBinderAsyncClosure , UnderscoreExprLhsAssign ,
66} ;
77use super :: ResolverAstLoweringExt ;
88use super :: { ImplTraitContext , LoweringContext , ParamMode , ParenthesizedGenericArgs } ;
@@ -188,7 +188,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
188188 e. id ,
189189 None ,
190190 e. span ,
191- hir:: AsyncGeneratorKind :: Block ,
191+ hir:: AsyncCoroutineKind :: Block ,
192192 |this| this. with_new_scopes ( |this| this. lower_block_expr ( block) ) ,
193193 ) ,
194194 ExprKind :: Await ( expr, await_kw_span) => self . lower_expr_await ( * await_kw_span, expr) ,
@@ -583,7 +583,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
583583 }
584584 }
585585
586- /// Lower an `async` construct to a generator that implements `Future`.
586+ /// Lower an `async` construct to a coroutine that implements `Future`.
587587 ///
588588 /// This results in:
589589 ///
@@ -598,7 +598,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
598598 closure_node_id : NodeId ,
599599 ret_ty : Option < hir:: FnRetTy < ' hir > > ,
600600 span : Span ,
601- async_gen_kind : hir:: AsyncGeneratorKind ,
601+ async_gen_kind : hir:: AsyncCoroutineKind ,
602602 body : impl FnOnce ( & mut Self ) -> hir:: Expr < ' hir > ,
603603 ) -> hir:: ExprKind < ' hir > {
604604 let output = ret_ty. unwrap_or_else ( || hir:: FnRetTy :: DefaultReturn ( self . lower_span ( span) ) ) ;
@@ -613,7 +613,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
613613 span : unstable_span,
614614 } ;
615615
616- // The closure/generator `FnDecl` takes a single (resume) argument of type `input_ty`.
616+ // The closure/coroutine `FnDecl` takes a single (resume) argument of type `input_ty`.
617617 let fn_decl = self . arena . alloc ( hir:: FnDecl {
618618 inputs : arena_vec ! [ self ; input_ty] ,
619619 output,
@@ -637,7 +637,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
637637 let params = arena_vec ! [ self ; param] ;
638638
639639 let body = self . lower_body ( move |this| {
640- this. generator_kind = Some ( hir:: GeneratorKind :: Async ( async_gen_kind) ) ;
640+ this. coroutine_kind = Some ( hir:: CoroutineKind :: Async ( async_gen_kind) ) ;
641641
642642 let old_ctx = this. task_context ;
643643 this. task_context = Some ( task_context_hid) ;
@@ -710,9 +710,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
710710 /// ```
711711 fn lower_expr_await ( & mut self , await_kw_span : Span , expr : & Expr ) -> hir:: ExprKind < ' hir > {
712712 let full_span = expr. span . to ( await_kw_span) ;
713- match self . generator_kind {
714- Some ( hir:: GeneratorKind :: Async ( _) ) => { }
715- Some ( hir:: GeneratorKind :: Gen ) | None => {
713+ match self . coroutine_kind {
714+ Some ( hir:: CoroutineKind :: Async ( _) ) => { }
715+ Some ( hir:: CoroutineKind :: Coroutine ) | None => {
716716 self . tcx . sess . emit_err ( AwaitOnlyInAsyncFnAndBlocks {
717717 await_kw_span,
718718 item_span : self . current_item ,
@@ -887,19 +887,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
887887 ) -> hir:: ExprKind < ' hir > {
888888 let ( binder_clause, generic_params) = self . lower_closure_binder ( binder) ;
889889
890- let ( body_id, generator_option ) = self . with_new_scopes ( move |this| {
890+ let ( body_id, coroutine_option ) = self . with_new_scopes ( move |this| {
891891 let prev = this. current_item ;
892892 this. current_item = Some ( fn_decl_span) ;
893- let mut generator_kind = None ;
893+ let mut coroutine_kind = None ;
894894 let body_id = this. lower_fn_body ( decl, |this| {
895895 let e = this. lower_expr_mut ( body) ;
896- generator_kind = this. generator_kind ;
896+ coroutine_kind = this. coroutine_kind ;
897897 e
898898 } ) ;
899- let generator_option =
900- this. generator_movability_for_fn ( & decl, fn_decl_span, generator_kind , movability) ;
899+ let coroutine_option =
900+ this. coroutine_movability_for_fn ( & decl, fn_decl_span, coroutine_kind , movability) ;
901901 this. current_item = prev;
902- ( body_id, generator_option )
902+ ( body_id, coroutine_option )
903903 } ) ;
904904
905905 let bound_generic_params = self . lower_lifetime_binder ( closure_id, generic_params) ;
@@ -915,28 +915,28 @@ impl<'hir> LoweringContext<'_, 'hir> {
915915 body : body_id,
916916 fn_decl_span : self . lower_span ( fn_decl_span) ,
917917 fn_arg_span : Some ( self . lower_span ( fn_arg_span) ) ,
918- movability : generator_option ,
918+ movability : coroutine_option ,
919919 constness : self . lower_constness ( constness) ,
920920 } ) ;
921921
922922 hir:: ExprKind :: Closure ( c)
923923 }
924924
925- fn generator_movability_for_fn (
925+ fn coroutine_movability_for_fn (
926926 & mut self ,
927927 decl : & FnDecl ,
928928 fn_decl_span : Span ,
929- generator_kind : Option < hir:: GeneratorKind > ,
929+ coroutine_kind : Option < hir:: CoroutineKind > ,
930930 movability : Movability ,
931931 ) -> Option < hir:: Movability > {
932- match generator_kind {
933- Some ( hir:: GeneratorKind :: Gen ) => {
932+ match coroutine_kind {
933+ Some ( hir:: CoroutineKind :: Coroutine ) => {
934934 if decl. inputs . len ( ) > 1 {
935- self . tcx . sess . emit_err ( GeneratorTooManyParameters { fn_decl_span } ) ;
935+ self . tcx . sess . emit_err ( CoroutineTooManyParameters { fn_decl_span } ) ;
936936 }
937937 Some ( movability)
938938 }
939- Some ( hir:: GeneratorKind :: Async ( _) ) => {
939+ Some ( hir:: CoroutineKind :: Async ( _) ) => {
940940 panic ! ( "non-`async` closure body turned `async` during lowering" ) ;
941941 }
942942 None => {
@@ -1005,7 +1005,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10051005 inner_closure_id,
10061006 async_ret_ty,
10071007 body. span ,
1008- hir:: AsyncGeneratorKind :: Closure ,
1008+ hir:: AsyncCoroutineKind :: Closure ,
10091009 |this| this. with_new_scopes ( |this| this. lower_expr_mut ( body) ) ,
10101010 ) ;
10111011 let hir_id = this. lower_node_id ( inner_closure_id) ;
@@ -1444,12 +1444,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
14441444 }
14451445
14461446 fn lower_expr_yield ( & mut self , span : Span , opt_expr : Option < & Expr > ) -> hir:: ExprKind < ' hir > {
1447- match self . generator_kind {
1448- Some ( hir:: GeneratorKind :: Gen ) => { }
1449- Some ( hir:: GeneratorKind :: Async ( _) ) => {
1450- self . tcx . sess . emit_err ( AsyncGeneratorsNotSupported { span } ) ;
1447+ match self . coroutine_kind {
1448+ Some ( hir:: CoroutineKind :: Coroutine ) => { }
1449+ Some ( hir:: CoroutineKind :: Async ( _) ) => {
1450+ self . tcx . sess . emit_err ( AsyncCoroutinesNotSupported { span } ) ;
14511451 }
1452- None => self . generator_kind = Some ( hir:: GeneratorKind :: Gen ) ,
1452+ None => self . coroutine_kind = Some ( hir:: CoroutineKind :: Coroutine ) ,
14531453 }
14541454
14551455 let expr =
0 commit comments