@@ -31,6 +31,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
3131
3232 pub ( super ) fn lower_expr_mut ( & mut self , e : & Expr ) -> hir:: Expr < ' hir > {
3333 ensure_sufficient_stack ( || {
34+ let hir_id = self . lower_node_id ( e. id ) ;
35+ self . lower_attrs ( hir_id, & e. attrs ) ;
36+
3437 let kind = match & e. kind {
3538 ExprKind :: Box ( inner) => hir:: ExprKind :: Box ( self . lower_expr ( inner) ) ,
3639 ExprKind :: Array ( exprs) => hir:: ExprKind :: Array ( self . lower_exprs ( exprs) ) ,
@@ -147,7 +150,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
147150 ) ,
148151 ExprKind :: Async ( capture_clause, closure_node_id, block) => self . make_async_expr (
149152 * capture_clause,
150- None ,
153+ hir_id ,
151154 * closure_node_id,
152155 None ,
153156 e. span ,
@@ -184,6 +187,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
184187 binder,
185188 * capture_clause,
186189 e. id ,
190+ hir_id,
187191 * closure_id,
188192 fn_decl,
189193 body,
@@ -310,8 +314,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
310314 ExprKind :: MacCall ( _) => panic ! ( "{:?} shouldn't exist here" , e. span) ,
311315 } ;
312316
313- let hir_id = self . lower_node_id ( e. id ) ;
314- self . lower_attrs ( hir_id, & e. attrs ) ;
315317 hir:: Expr { hir_id, kind, span : self . lower_span ( e. span ) }
316318 } )
317319 }
@@ -576,7 +578,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
576578 pub ( super ) fn make_async_expr (
577579 & mut self ,
578580 capture_clause : CaptureBy ,
579- outer_hir_id : Option < hir:: HirId > ,
581+ outer_hir_id : hir:: HirId ,
580582 closure_node_id : NodeId ,
581583 ret_ty : Option < hir:: FnRetTy < ' hir > > ,
582584 span : Span ,
@@ -669,8 +671,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
669671 hir:: ExprKind :: Closure ( c)
670672 } ;
671673
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 )
674677 . map_or ( false , |attrs| attrs. into_iter ( ) . any ( |attr| attr. has_name ( sym:: track_caller) ) ) ;
675678
676679 let hir_id = self . lower_node_id ( closure_node_id) ;
@@ -985,6 +988,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
985988 binder : & ClosureBinder ,
986989 capture_clause : CaptureBy ,
987990 closure_id : NodeId ,
991+ closure_hir_id : hir:: HirId ,
988992 inner_closure_id : NodeId ,
989993 decl : & FnDecl ,
990994 body : & Expr ,
@@ -1018,9 +1022,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10181022
10191023 let async_body = this. make_async_expr (
10201024 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,
10241026 inner_closure_id,
10251027 async_ret_ty,
10261028 body. span ,
0 commit comments