@@ -253,8 +253,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
253
253
// only cares about the input argument patterns in the function
254
254
// declaration (decl), not the return types.
255
255
let asyncness = header. asyncness ;
256
- let body_id =
257
- this. lower_maybe_async_body ( span, & decl, asyncness, body. as_deref ( ) ) ;
256
+ let body_id = this. lower_maybe_async_body (
257
+ span,
258
+ hir_id,
259
+ & decl,
260
+ asyncness,
261
+ body. as_deref ( ) ,
262
+ ) ;
258
263
259
264
let mut itctx = ImplTraitContext :: Universal ;
260
265
let ( generics, decl) = this. lower_generics ( generics, id, & mut itctx, |this| {
@@ -701,6 +706,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
701
706
702
707
fn lower_trait_item ( & mut self , i : & AssocItem ) -> & ' hir hir:: TraitItem < ' hir > {
703
708
let hir_id = self . lower_node_id ( i. id ) ;
709
+ self . lower_attrs ( hir_id, & i. attrs ) ;
704
710
let trait_item_def_id = hir_id. expect_owner ( ) ;
705
711
706
712
let ( generics, kind, has_default) = match & i. kind {
@@ -724,7 +730,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
724
730
AssocItemKind :: Fn ( box Fn { sig, generics, body : Some ( body) , .. } ) => {
725
731
let asyncness = sig. header . asyncness ;
726
732
let body_id =
727
- self . lower_maybe_async_body ( i. span , & sig. decl , asyncness, Some ( & body) ) ;
733
+ self . lower_maybe_async_body ( i. span , hir_id , & sig. decl , asyncness, Some ( & body) ) ;
728
734
let ( generics, sig) = self . lower_method_sig (
729
735
generics,
730
736
sig,
@@ -759,7 +765,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
759
765
AssocItemKind :: MacCall ( ..) => panic ! ( "macro item shouldn't exist at this point" ) ,
760
766
} ;
761
767
762
- self . lower_attrs ( hir_id, & i. attrs ) ;
763
768
let item = hir:: TraitItem {
764
769
owner_id : trait_item_def_id,
765
770
ident : self . lower_ident ( i. ident ) ,
@@ -798,6 +803,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
798
803
// Since `default impl` is not yet implemented, this is always true in impls.
799
804
let has_value = true ;
800
805
let ( defaultness, _) = self . lower_defaultness ( i. kind . defaultness ( ) , has_value) ;
806
+ let hir_id = self . lower_node_id ( i. id ) ;
807
+ self . lower_attrs ( hir_id, & i. attrs ) ;
801
808
802
809
let ( generics, kind) = match & i. kind {
803
810
AssocItemKind :: Const ( _, ty, expr) => {
@@ -810,8 +817,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
810
817
AssocItemKind :: Fn ( box Fn { sig, generics, body, .. } ) => {
811
818
self . current_item = Some ( i. span ) ;
812
819
let asyncness = sig. header . asyncness ;
813
- let body_id =
814
- self . lower_maybe_async_body ( i. span , & sig. decl , asyncness, body. as_deref ( ) ) ;
820
+ let body_id = self . lower_maybe_async_body (
821
+ i. span ,
822
+ hir_id,
823
+ & sig. decl ,
824
+ asyncness,
825
+ body. as_deref ( ) ,
826
+ ) ;
815
827
let ( generics, sig) = self . lower_method_sig (
816
828
generics,
817
829
sig,
@@ -844,8 +856,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
844
856
AssocItemKind :: MacCall ( ..) => panic ! ( "`TyMac` should have been expanded by now" ) ,
845
857
} ;
846
858
847
- let hir_id = self . lower_node_id ( i. id ) ;
848
- self . lower_attrs ( hir_id, & i. attrs ) ;
849
859
let item = hir:: ImplItem {
850
860
owner_id : hir_id. expect_owner ( ) ,
851
861
ident : self . lower_ident ( i. ident ) ,
@@ -978,6 +988,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
978
988
fn lower_maybe_async_body (
979
989
& mut self ,
980
990
span : Span ,
991
+ fn_id : hir:: HirId ,
981
992
decl : & FnDecl ,
982
993
asyncness : Async ,
983
994
body : Option < & Block > ,
@@ -1128,6 +1139,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1128
1139
1129
1140
let async_expr = this. make_async_expr (
1130
1141
CaptureBy :: Value ,
1142
+ Some ( fn_id) ,
1131
1143
closure_id,
1132
1144
None ,
1133
1145
body. span ,
0 commit comments