@@ -1055,9 +1055,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1055
1055
asyncness : Async ,
1056
1056
body : Option < & Block > ,
1057
1057
) -> hir:: BodyId {
1058
- let closure_id = match asyncness {
1059
- Async :: Yes { closure_id, .. } => closure_id,
1060
- Async :: No => return self . lower_fn_body_block ( span, decl, body) ,
1058
+ let ( closure_id, body ) = match ( asyncness, body ) {
1059
+ ( Async :: Yes { closure_id, .. } , Some ( body ) ) => ( closure_id, body ) ,
1060
+ _ => return self . lower_fn_body_block ( span, decl, body) ,
1061
1061
} ;
1062
1062
1063
1063
self . lower_body ( |this| {
@@ -1199,16 +1199,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
1199
1199
parameters. push ( new_parameter) ;
1200
1200
}
1201
1201
1202
- let body_span = body. map_or ( span, |b| b. span ) ;
1203
1202
let async_expr = this. make_async_expr (
1204
1203
CaptureBy :: Value ,
1205
1204
closure_id,
1206
1205
None ,
1207
- body_span ,
1206
+ body . span ,
1208
1207
hir:: AsyncGeneratorKind :: Fn ,
1209
1208
|this| {
1210
1209
// Create a block from the user's function body:
1211
- let user_body = this. lower_block_expr_opt ( body_span , body) ;
1210
+ let user_body = this. lower_block_expr ( body) ;
1212
1211
1213
1212
// Transform into `drop-temps { <user-body> }`, an expression:
1214
1213
let desugared_span =
@@ -1240,7 +1239,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1240
1239
1241
1240
(
1242
1241
this. arena . alloc_from_iter ( parameters) ,
1243
- this. expr ( body_span , async_expr, AttrVec :: new ( ) ) ,
1242
+ this. expr ( body . span , async_expr, AttrVec :: new ( ) ) ,
1244
1243
)
1245
1244
} )
1246
1245
}
0 commit comments