@@ -3034,7 +3034,7 @@ impl<'a> LoweringContext<'a> {
3034
3034
3035
3035
self . lower_body ( |this| {
3036
3036
let mut arguments: Vec < hir:: Arg > = Vec :: new ( ) ;
3037
- let mut statements: Vec < ( hir:: Stmt , Option < hir :: Stmt > ) > = Vec :: new ( ) ;
3037
+ let mut statements: Vec < hir:: Stmt > = Vec :: new ( ) ;
3038
3038
3039
3039
// Async function arguments are lowered into the closure body so that they are
3040
3040
// captured and so that the drop order matches the equivalent non-async functions.
@@ -3094,14 +3094,14 @@ impl<'a> LoweringContext<'a> {
3094
3094
source : hir:: ArgSource :: AsyncFn
3095
3095
} ;
3096
3096
3097
- let new_statements = if is_simple_argument {
3097
+ if is_simple_argument {
3098
3098
// If this is the simple case, then we only insert one statement that is
3099
3099
// `let <pat> = <pat>;`. We re-use the original argument's pattern so that
3100
3100
// `HirId`s are densely assigned.
3101
3101
let expr = this. expr_ident ( desugared_span, ident, new_argument_id) ;
3102
3102
let stmt = this. stmt_let_pat (
3103
3103
desugared_span, Some ( P ( expr) ) , argument. pat , hir:: LocalSource :: AsyncFn ) ;
3104
- ( stmt, None )
3104
+ statements . push ( stmt) ;
3105
3105
} else {
3106
3106
// If this is not the simple case, then we construct two statements:
3107
3107
//
@@ -3131,26 +3131,17 @@ impl<'a> LoweringContext<'a> {
3131
3131
desugared_span, Some ( P ( pattern_expr) ) , argument. pat ,
3132
3132
hir:: LocalSource :: AsyncFn ) ;
3133
3133
3134
- ( move_stmt, Some ( pattern_stmt) )
3134
+ statements. push ( move_stmt) ;
3135
+ statements. push ( pattern_stmt) ;
3135
3136
} ;
3136
3137
3137
3138
arguments. push ( new_argument) ;
3138
- statements. push ( new_statements) ;
3139
3139
}
3140
3140
3141
3141
let async_expr = this. make_async_expr (
3142
3142
CaptureBy :: Value , closure_id, None , body. span ,
3143
3143
|this| {
3144
- let mut stmts = vec ! [ ] ;
3145
- for ( move_stmt, pattern_stmt) in statements. drain ( ..) {
3146
- // Insert the `let __argN = __argN` statement first.
3147
- stmts. push ( move_stmt) ;
3148
- // Then insert the `let <pat> = __argN` statement, if there is one.
3149
- if let Some ( pattern_stmt) = pattern_stmt {
3150
- stmts. push ( pattern_stmt) ;
3151
- }
3152
- }
3153
- let body = this. lower_block_with_stmts ( body, false , stmts) ;
3144
+ let body = this. lower_block_with_stmts ( body, false , statements) ;
3154
3145
this. expr_block ( body, ThinVec :: new ( ) )
3155
3146
} ) ;
3156
3147
( HirVec :: from ( arguments) , this. expr ( body. span , async_expr, ThinVec :: new ( ) ) )
@@ -5220,10 +5211,6 @@ impl<'a> LoweringContext<'a> {
5220
5211
}
5221
5212
}
5222
5213
5223
- fn arg ( & mut self , hir_id : hir:: HirId , pat : P < hir:: Pat > , source : hir:: ArgSource ) -> hir:: Arg {
5224
- hir:: Arg { hir_id, pat, source }
5225
- }
5226
-
5227
5214
fn stmt ( & mut self , span : Span , node : hir:: StmtKind ) -> hir:: Stmt {
5228
5215
hir:: Stmt { span, node, hir_id : self . next_id ( ) }
5229
5216
}
0 commit comments