@@ -1969,14 +1969,21 @@ pub enum TraitItemKind<'hir> {
19691969// so it can fetched later.
19701970#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Encodable , Debug ) ]
19711971pub struct ImplItemId {
1972- pub hir_id : HirId ,
1972+ pub def_id : LocalDefId ,
1973+ }
1974+
1975+ impl ImplItemId {
1976+ pub fn hir_id ( & self ) -> HirId {
1977+ // Items are always HIR owners.
1978+ HirId :: make_owner ( self . def_id )
1979+ }
19731980}
19741981
19751982/// Represents anything within an `impl` block.
19761983#[ derive( Debug ) ]
19771984pub struct ImplItem < ' hir > {
19781985 pub ident : Ident ,
1979- pub hir_id : HirId ,
1986+ pub def_id : LocalDefId ,
19801987 pub vis : Visibility < ' hir > ,
19811988 pub defaultness : Defaultness ,
19821989 pub attrs : & ' hir [ Attribute ] ,
@@ -1985,6 +1992,17 @@ pub struct ImplItem<'hir> {
19851992 pub span : Span ,
19861993}
19871994
1995+ impl ImplItem < ' _ > {
1996+ pub fn hir_id ( & self ) -> HirId {
1997+ // Items are always HIR owners.
1998+ HirId :: make_owner ( self . def_id )
1999+ }
2000+
2001+ pub fn impl_item_id ( & self ) -> ImplItemId {
2002+ ImplItemId { def_id : self . def_id }
2003+ }
2004+ }
2005+
19882006/// Represents various kinds of content within an `impl`.
19892007#[ derive( Debug , HashStable_Generic ) ]
19902008pub enum ImplItemKind < ' hir > {
@@ -2903,11 +2921,10 @@ impl<'hir> Node<'hir> {
29032921
29042922 pub fn hir_id ( & self ) -> Option < HirId > {
29052923 match self {
2906- Node :: Item ( Item { def_id, .. } ) | Node :: TraitItem ( TraitItem { def_id , .. } ) => {
2907- Some ( HirId :: make_owner ( * def_id) )
2908- }
2924+ Node :: Item ( Item { def_id, .. } )
2925+ | Node :: TraitItem ( TraitItem { def_id, .. } )
2926+ | Node :: ImplItem ( ImplItem { def_id , .. } ) => Some ( HirId :: make_owner ( * def_id ) ) ,
29092927 Node :: ForeignItem ( ForeignItem { hir_id, .. } )
2910- | Node :: ImplItem ( ImplItem { hir_id, .. } )
29112928 | Node :: Field ( StructField { hir_id, .. } )
29122929 | Node :: AnonConst ( AnonConst { hir_id, .. } )
29132930 | Node :: Expr ( Expr { hir_id, .. } )
0 commit comments