@@ -1055,9 +1055,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
10551055 asyncness : Async ,
10561056 body : Option < & Block > ,
10571057 ) -> 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) ,
10611061 } ;
10621062
10631063 self . lower_body ( |this| {
@@ -1199,16 +1199,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
11991199 parameters. push ( new_parameter) ;
12001200 }
12011201
1202- let body_span = body. map_or ( span, |b| b. span ) ;
12031202 let async_expr = this. make_async_expr (
12041203 CaptureBy :: Value ,
12051204 closure_id,
12061205 None ,
1207- body_span ,
1206+ body . span ,
12081207 hir:: AsyncGeneratorKind :: Fn ,
12091208 |this| {
12101209 // 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) ;
12121211
12131212 // Transform into `drop-temps { <user-body> }`, an expression:
12141213 let desugared_span =
@@ -1240,7 +1239,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12401239
12411240 (
12421241 this. arena . alloc_from_iter ( parameters) ,
1243- this. expr ( body_span , async_expr, AttrVec :: new ( ) ) ,
1242+ this. expr ( body . span , async_expr, AttrVec :: new ( ) ) ,
12441243 )
12451244 } )
12461245 }
0 commit comments