@@ -2520,6 +2520,28 @@ impl<'a> LoweringContext<'a> {
2520
2520
} )
2521
2521
}
2522
2522
2523
+ fn lower_async_body (
2524
+ & mut self ,
2525
+ decl : & FnDecl ,
2526
+ asyncness : IsAsync ,
2527
+ body : & Block ,
2528
+ ) -> hir:: BodyId {
2529
+ self . lower_body ( Some ( decl) , |this| {
2530
+ if let IsAsync :: Async ( async_node_id) = asyncness {
2531
+ let async_expr = this. make_async_expr (
2532
+ CaptureBy :: Value , async_node_id, None ,
2533
+ |this| {
2534
+ let body = this. lower_block ( body, false ) ;
2535
+ this. expr_block ( body, ThinVec :: new ( ) )
2536
+ } ) ;
2537
+ this. expr ( body. span , async_expr, ThinVec :: new ( ) )
2538
+ } else {
2539
+ let body = this. lower_block ( body, false ) ;
2540
+ this. expr_block ( body, ThinVec :: new ( ) )
2541
+ }
2542
+ } )
2543
+ }
2544
+
2523
2545
fn lower_item_kind (
2524
2546
& mut self ,
2525
2547
id : NodeId ,
@@ -2559,20 +2581,7 @@ impl<'a> LoweringContext<'a> {
2559
2581
// `impl Future<Output = T>` here because lower_body
2560
2582
// only cares about the input argument patterns in the function
2561
2583
// declaration (decl), not the return types.
2562
- let body_id = this. lower_body ( Some ( decl) , |this| {
2563
- if let IsAsync :: Async { closure_id, .. } = header. asyncness {
2564
- let async_expr = this. make_async_expr (
2565
- CaptureBy :: Value , closure_id, None ,
2566
- |this| {
2567
- let body = this. lower_block ( body, false ) ;
2568
- this. expr_block ( body, ThinVec :: new ( ) )
2569
- } ) ;
2570
- this. expr ( body. span , async_expr, ThinVec :: new ( ) )
2571
- } else {
2572
- let body = this. lower_block ( body, false ) ;
2573
- this. expr_block ( body, ThinVec :: new ( ) )
2574
- }
2575
- } ) ;
2584
+ let body_id = this. lower_async_body ( decl, header. asyncness , body) ;
2576
2585
2577
2586
let ( generics, fn_decl) = this. add_in_band_defs (
2578
2587
generics,
@@ -2990,20 +2999,7 @@ impl<'a> LoweringContext<'a> {
2990
2999
)
2991
3000
}
2992
3001
ImplItemKind :: Method ( ref sig, ref body) => {
2993
- let body_id = self . lower_body ( Some ( & sig. decl ) , |this| {
2994
- if let IsAsync :: Async { closure_id, .. } = sig. header . asyncness {
2995
- let async_expr = this. make_async_expr (
2996
- CaptureBy :: Value , closure_id, None ,
2997
- |this| {
2998
- let body = this. lower_block ( body, false ) ;
2999
- this. expr_block ( body, ThinVec :: new ( ) )
3000
- } ) ;
3001
- this. expr ( body. span , async_expr, ThinVec :: new ( ) )
3002
- } else {
3003
- let body = this. lower_block ( body, false ) ;
3004
- this. expr_block ( body, ThinVec :: new ( ) )
3005
- }
3006
- } ) ;
3002
+ let body_id = self . lower_async_body ( & sig. decl , sig. header . asyncness , body) ;
3007
3003
let impl_trait_return_allow = !self . is_in_trait_impl ;
3008
3004
3009
3005
self . add_in_band_defs (
0 commit comments