@@ -31,6 +31,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
31
31
32
32
pub ( super ) fn lower_expr_mut ( & mut self , e : & Expr ) -> hir:: Expr < ' hir > {
33
33
ensure_sufficient_stack ( || {
34
+ let hir_id = self . lower_node_id ( e. id ) ;
35
+ self . lower_attrs ( hir_id, & e. attrs ) ;
36
+
34
37
let kind = match & e. kind {
35
38
ExprKind :: Box ( inner) => hir:: ExprKind :: Box ( self . lower_expr ( inner) ) ,
36
39
ExprKind :: Array ( exprs) => hir:: ExprKind :: Array ( self . lower_exprs ( exprs) ) ,
@@ -147,7 +150,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
147
150
) ,
148
151
ExprKind :: Async ( capture_clause, closure_node_id, block) => self . make_async_expr (
149
152
* capture_clause,
150
- None ,
153
+ hir_id ,
151
154
* closure_node_id,
152
155
None ,
153
156
e. span ,
@@ -184,6 +187,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
184
187
binder,
185
188
* capture_clause,
186
189
e. id ,
190
+ hir_id,
187
191
* closure_id,
188
192
fn_decl,
189
193
body,
@@ -310,8 +314,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
310
314
ExprKind :: MacCall ( _) => panic ! ( "{:?} shouldn't exist here" , e. span) ,
311
315
} ;
312
316
313
- let hir_id = self . lower_node_id ( e. id ) ;
314
- self . lower_attrs ( hir_id, & e. attrs ) ;
315
317
hir:: Expr { hir_id, kind, span : self . lower_span ( e. span ) }
316
318
} )
317
319
}
@@ -576,7 +578,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
576
578
pub ( super ) fn make_async_expr (
577
579
& mut self ,
578
580
capture_clause : CaptureBy ,
579
- outer_hir_id : Option < hir:: HirId > ,
581
+ outer_hir_id : hir:: HirId ,
580
582
closure_node_id : NodeId ,
581
583
ret_ty : Option < hir:: FnRetTy < ' hir > > ,
582
584
span : Span ,
@@ -669,8 +671,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
669
671
hir:: ExprKind :: Closure ( c)
670
672
} ;
671
673
672
- let track_caller = outer_hir_id
673
- . and_then ( |id| self . attrs . get ( & id. local_id ) )
674
+ let track_caller = self
675
+ . attrs
676
+ . get ( & outer_hir_id. local_id )
674
677
. map_or ( false , |attrs| attrs. into_iter ( ) . any ( |attr| attr. has_name ( sym:: track_caller) ) ) ;
675
678
676
679
let hir_id = self . lower_node_id ( closure_node_id) ;
@@ -985,6 +988,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
985
988
binder : & ClosureBinder ,
986
989
capture_clause : CaptureBy ,
987
990
closure_id : NodeId ,
991
+ closure_hir_id : hir:: HirId ,
988
992
inner_closure_id : NodeId ,
989
993
decl : & FnDecl ,
990
994
body : & Expr ,
@@ -1018,9 +1022,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1018
1022
1019
1023
let async_body = this. make_async_expr (
1020
1024
capture_clause,
1021
- // FIXME(nbdd0121): This should also use a proper HIR id so `#[track_caller]`
1022
- // can be applied on async closures as well.
1023
- None ,
1025
+ closure_hir_id,
1024
1026
inner_closure_id,
1025
1027
async_ret_ty,
1026
1028
body. span ,
0 commit comments