1
1
use 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 ,
6
6
} ;
7
7
use super :: ResolverAstLoweringExt ;
8
8
use super :: { ImplTraitContext , LoweringContext , ParamMode , ParenthesizedGenericArgs } ;
@@ -188,7 +188,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
188
188
e. id ,
189
189
None ,
190
190
e. span ,
191
- hir:: AsyncGeneratorKind :: Block ,
191
+ hir:: AsyncCoroutineKind :: Block ,
192
192
|this| this. with_new_scopes ( |this| this. lower_block_expr ( block) ) ,
193
193
) ,
194
194
ExprKind :: Await ( expr, await_kw_span) => self . lower_expr_await ( * await_kw_span, expr) ,
@@ -583,7 +583,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
583
583
}
584
584
}
585
585
586
- /// Lower an `async` construct to a generator that implements `Future`.
586
+ /// Lower an `async` construct to a coroutine that implements `Future`.
587
587
///
588
588
/// This results in:
589
589
///
@@ -598,7 +598,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
598
598
closure_node_id : NodeId ,
599
599
ret_ty : Option < hir:: FnRetTy < ' hir > > ,
600
600
span : Span ,
601
- async_gen_kind : hir:: AsyncGeneratorKind ,
601
+ async_gen_kind : hir:: AsyncCoroutineKind ,
602
602
body : impl FnOnce ( & mut Self ) -> hir:: Expr < ' hir > ,
603
603
) -> hir:: ExprKind < ' hir > {
604
604
let output = ret_ty. unwrap_or_else ( || hir:: FnRetTy :: DefaultReturn ( self . lower_span ( span) ) ) ;
@@ -613,7 +613,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
613
613
span : unstable_span,
614
614
} ;
615
615
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`.
617
617
let fn_decl = self . arena . alloc ( hir:: FnDecl {
618
618
inputs : arena_vec ! [ self ; input_ty] ,
619
619
output,
@@ -637,7 +637,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
637
637
let params = arena_vec ! [ self ; param] ;
638
638
639
639
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) ) ;
641
641
642
642
let old_ctx = this. task_context ;
643
643
this. task_context = Some ( task_context_hid) ;
@@ -710,9 +710,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
710
710
/// ```
711
711
fn lower_expr_await ( & mut self , await_kw_span : Span , expr : & Expr ) -> hir:: ExprKind < ' hir > {
712
712
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 => {
716
716
self . tcx . sess . emit_err ( AwaitOnlyInAsyncFnAndBlocks {
717
717
await_kw_span,
718
718
item_span : self . current_item ,
@@ -887,19 +887,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
887
887
) -> hir:: ExprKind < ' hir > {
888
888
let ( binder_clause, generic_params) = self . lower_closure_binder ( binder) ;
889
889
890
- let ( body_id, generator_option ) = self . with_new_scopes ( move |this| {
890
+ let ( body_id, coroutine_option ) = self . with_new_scopes ( move |this| {
891
891
let prev = this. current_item ;
892
892
this. current_item = Some ( fn_decl_span) ;
893
- let mut generator_kind = None ;
893
+ let mut coroutine_kind = None ;
894
894
let body_id = this. lower_fn_body ( decl, |this| {
895
895
let e = this. lower_expr_mut ( body) ;
896
- generator_kind = this. generator_kind ;
896
+ coroutine_kind = this. coroutine_kind ;
897
897
e
898
898
} ) ;
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) ;
901
901
this. current_item = prev;
902
- ( body_id, generator_option )
902
+ ( body_id, coroutine_option )
903
903
} ) ;
904
904
905
905
let bound_generic_params = self . lower_lifetime_binder ( closure_id, generic_params) ;
@@ -915,28 +915,28 @@ impl<'hir> LoweringContext<'_, 'hir> {
915
915
body : body_id,
916
916
fn_decl_span : self . lower_span ( fn_decl_span) ,
917
917
fn_arg_span : Some ( self . lower_span ( fn_arg_span) ) ,
918
- movability : generator_option ,
918
+ movability : coroutine_option ,
919
919
constness : self . lower_constness ( constness) ,
920
920
} ) ;
921
921
922
922
hir:: ExprKind :: Closure ( c)
923
923
}
924
924
925
- fn generator_movability_for_fn (
925
+ fn coroutine_movability_for_fn (
926
926
& mut self ,
927
927
decl : & FnDecl ,
928
928
fn_decl_span : Span ,
929
- generator_kind : Option < hir:: GeneratorKind > ,
929
+ coroutine_kind : Option < hir:: CoroutineKind > ,
930
930
movability : Movability ,
931
931
) -> Option < hir:: Movability > {
932
- match generator_kind {
933
- Some ( hir:: GeneratorKind :: Gen ) => {
932
+ match coroutine_kind {
933
+ Some ( hir:: CoroutineKind :: Coroutine ) => {
934
934
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 } ) ;
936
936
}
937
937
Some ( movability)
938
938
}
939
- Some ( hir:: GeneratorKind :: Async ( _) ) => {
939
+ Some ( hir:: CoroutineKind :: Async ( _) ) => {
940
940
panic ! ( "non-`async` closure body turned `async` during lowering" ) ;
941
941
}
942
942
None => {
@@ -1005,7 +1005,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1005
1005
inner_closure_id,
1006
1006
async_ret_ty,
1007
1007
body. span ,
1008
- hir:: AsyncGeneratorKind :: Closure ,
1008
+ hir:: AsyncCoroutineKind :: Closure ,
1009
1009
|this| this. with_new_scopes ( |this| this. lower_expr_mut ( body) ) ,
1010
1010
) ;
1011
1011
let hir_id = this. lower_node_id ( inner_closure_id) ;
@@ -1444,12 +1444,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
1444
1444
}
1445
1445
1446
1446
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 } ) ;
1451
1451
}
1452
- None => self . generator_kind = Some ( hir:: GeneratorKind :: Gen ) ,
1452
+ None => self . coroutine_kind = Some ( hir:: CoroutineKind :: Coroutine ) ,
1453
1453
}
1454
1454
1455
1455
let expr =
0 commit comments