@@ -2,8 +2,7 @@ use super::errors::{
2
2
AsyncCoroutinesNotSupported , AwaitOnlyInAsyncFnAndBlocks , BaseExpressionDoubleDot ,
3
3
ClosureCannotBeStatic , CoroutineTooManyParameters ,
4
4
FunctionalRecordUpdateDestructuringAssignment , InclusiveRangeWithNoEnd , MatchArmWithNoBody ,
5
- NeverPatternWithBody , NeverPatternWithGuard , NotSupportedForLifetimeBinderAsyncClosure ,
6
- UnderscoreExprLhsAssign ,
5
+ NeverPatternWithBody , NeverPatternWithGuard , UnderscoreExprLhsAssign ,
7
6
} ;
8
7
use super :: ResolverAstLoweringExt ;
9
8
use super :: { ImplTraitContext , LoweringContext , ParamMode , ParenthesizedGenericArgs } ;
@@ -1026,30 +1025,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
1026
1025
fn_decl_span : Span ,
1027
1026
fn_arg_span : Span ,
1028
1027
) -> hir:: ExprKind < ' hir > {
1029
- if let & ClosureBinder :: For { span, .. } = binder {
1030
- self . dcx ( ) . emit_err ( NotSupportedForLifetimeBinderAsyncClosure { span } ) ;
1031
- }
1032
-
1033
1028
let ( binder_clause, generic_params) = self . lower_closure_binder ( binder) ;
1034
1029
1035
1030
let body = self . with_new_scopes ( fn_decl_span, |this| {
1031
+ let inner_decl =
1032
+ FnDecl { inputs : decl. inputs . clone ( ) , output : FnRetTy :: Default ( fn_decl_span) } ;
1033
+
1036
1034
// Transform `async |x: u8| -> X { ... }` into
1037
1035
// `|x: u8| || -> X { ... }`.
1038
1036
let body_id = this. lower_body ( |this| {
1039
- let async_ret_ty = if let FnRetTy :: Ty ( ty) = & decl. output {
1040
- let itctx = ImplTraitContext :: Disallowed ( ImplTraitPosition :: AsyncBlock ) ;
1041
- Some ( hir:: FnRetTy :: Return ( this. lower_ty ( ty, & itctx) ) )
1042
- } else {
1043
- None
1044
- } ;
1045
-
1046
1037
let ( parameters, expr) = this. lower_coroutine_body_with_moved_arguments (
1047
- decl ,
1038
+ & inner_decl ,
1048
1039
|this| this. with_new_scopes ( fn_decl_span, |this| this. lower_expr_mut ( body) ) ,
1049
1040
body. span ,
1050
1041
coroutine_kind,
1051
1042
hir:: CoroutineSource :: Closure ,
1052
- async_ret_ty,
1053
1043
) ;
1054
1044
1055
1045
let hir_id = this. lower_node_id ( coroutine_kind. closure_id ( ) ) ;
@@ -1060,15 +1050,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
1060
1050
body_id
1061
1051
} ) ;
1062
1052
1063
- let outer_decl =
1064
- FnDecl { inputs : decl. inputs . clone ( ) , output : FnRetTy :: Default ( fn_decl_span) } ;
1065
-
1066
1053
let bound_generic_params = self . lower_lifetime_binder ( closure_id, generic_params) ;
1067
1054
// We need to lower the declaration outside the new scope, because we
1068
1055
// have to conserve the state of being inside a loop condition for the
1069
1056
// closure argument types.
1070
1057
let fn_decl =
1071
- self . lower_fn_decl ( & outer_decl , closure_id, fn_decl_span, FnDeclKind :: Closure , None ) ;
1058
+ self . lower_fn_decl ( & decl , closure_id, fn_decl_span, FnDeclKind :: Closure , None ) ;
1072
1059
1073
1060
let c = self . arena . alloc ( hir:: Closure {
1074
1061
def_id : self . local_def_id ( closure_id) ,
@@ -1079,7 +1066,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1079
1066
body,
1080
1067
fn_decl_span : self . lower_span ( fn_decl_span) ,
1081
1068
fn_arg_span : Some ( self . lower_span ( fn_arg_span) ) ,
1082
- kind : hir:: ClosureKind :: Closure ,
1069
+ kind : hir:: ClosureKind :: CoroutineClosure ( hir :: CoroutineDesugaring :: Async ) ,
1083
1070
constness : hir:: Constness :: NotConst ,
1084
1071
} ) ;
1085
1072
hir:: ExprKind :: Closure ( c)
0 commit comments