@@ -3529,12 +3529,20 @@ impl<'hir> OwnerNode<'hir> {
3529
3529
3530
3530
pub fn body_id ( & self ) -> Option < BodyId > {
3531
3531
match self {
3532
- OwnerNode :: TraitItem ( TraitItem {
3533
- kind : TraitItemKind :: Fn ( _, TraitFn :: Provided ( body_id) ) ,
3532
+ OwnerNode :: Item ( Item {
3533
+ kind :
3534
+ ItemKind :: Static ( _, _, body) | ItemKind :: Const ( _, body) | ItemKind :: Fn ( _, _, body) ,
3534
3535
..
3535
3536
} )
3536
- | OwnerNode :: ImplItem ( ImplItem { kind : ImplItemKind :: Fn ( _, body_id) , .. } )
3537
- | OwnerNode :: Item ( Item { kind : ItemKind :: Fn ( .., body_id) , .. } ) => Some ( * body_id) ,
3537
+ | OwnerNode :: TraitItem ( TraitItem {
3538
+ kind :
3539
+ TraitItemKind :: Fn ( _, TraitFn :: Provided ( body) ) | TraitItemKind :: Const ( _, Some ( body) ) ,
3540
+ ..
3541
+ } )
3542
+ | OwnerNode :: ImplItem ( ImplItem {
3543
+ kind : ImplItemKind :: Fn ( _, body) | ImplItemKind :: Const ( _, body) ,
3544
+ ..
3545
+ } ) => Some ( * body) ,
3538
3546
_ => None ,
3539
3547
}
3540
3548
}
@@ -3729,12 +3737,27 @@ impl<'hir> Node<'hir> {
3729
3737
3730
3738
pub fn body_id ( & self ) -> Option < BodyId > {
3731
3739
match self {
3732
- Node :: TraitItem ( TraitItem {
3733
- kind : TraitItemKind :: Fn ( _, TraitFn :: Provided ( body_id) ) ,
3740
+ Node :: Item ( Item {
3741
+ kind :
3742
+ ItemKind :: Static ( _, _, body) | ItemKind :: Const ( _, body) | ItemKind :: Fn ( _, _, body) ,
3743
+ ..
3744
+ } )
3745
+ | Node :: TraitItem ( TraitItem {
3746
+ kind :
3747
+ TraitItemKind :: Fn ( _, TraitFn :: Provided ( body) ) | TraitItemKind :: Const ( _, Some ( body) ) ,
3748
+ ..
3749
+ } )
3750
+ | Node :: ImplItem ( ImplItem {
3751
+ kind : ImplItemKind :: Fn ( _, body) | ImplItemKind :: Const ( _, body) ,
3734
3752
..
3735
3753
} )
3736
- | Node :: ImplItem ( ImplItem { kind : ImplItemKind :: Fn ( _, body_id) , .. } )
3737
- | Node :: Item ( Item { kind : ItemKind :: Fn ( .., body_id) , .. } ) => Some ( * body_id) ,
3754
+ | Node :: Expr ( Expr {
3755
+ kind :
3756
+ ExprKind :: ConstBlock ( AnonConst { body, .. } )
3757
+ | ExprKind :: Closure ( Closure { body, .. } )
3758
+ | ExprKind :: Repeat ( _, ArrayLen :: Body ( AnonConst { body, .. } ) ) ,
3759
+ ..
3760
+ } ) => Some ( * body) ,
3738
3761
_ => None ,
3739
3762
}
3740
3763
}
0 commit comments