@@ -3193,12 +3193,21 @@ pub struct ImplItem<'hir> {
31933193 pub owner_id : OwnerId ,
31943194 pub generics : & ' hir Generics < ' hir > ,
31953195 pub kind : ImplItemKind < ' hir > ,
3196- pub defaultness : Defaultness ,
3196+ pub impl_kind : ImplItemImplKind ,
31973197 pub span : Span ,
3198- pub vis_span : Span ,
31993198 pub has_delayed_lints : bool ,
3200- /// When we are in a trait impl, link to the trait-item's id.
3201- pub trait_item_def_id : Option < DefId > ,
3199+ }
3200+
3201+ #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
3202+ pub enum ImplItemImplKind {
3203+ Inherent {
3204+ vis_span : Span ,
3205+ } ,
3206+ Trait {
3207+ defaultness : Defaultness ,
3208+ /// Item in the trait that this item implements
3209+ trait_item_def_id : Result < DefId , ErrorGuaranteed > ,
3210+ } ,
32023211}
32033212
32043213impl < ' hir > ImplItem < ' hir > {
@@ -3212,6 +3221,13 @@ impl<'hir> ImplItem<'hir> {
32123221 ImplItemId { owner_id : self . owner_id }
32133222 }
32143223
3224+ pub fn vis_span ( & self ) -> Option < Span > {
3225+ match self . impl_kind {
3226+ ImplItemImplKind :: Trait { .. } => None ,
3227+ ImplItemImplKind :: Inherent { vis_span, .. } => Some ( vis_span) ,
3228+ }
3229+ }
3230+
32153231 expect_methods_self_kind ! {
32163232 expect_const, ( & ' hir Ty <' hir>, BodyId ) , ImplItemKind :: Const ( ty, body) , ( ty, * body) ;
32173233 expect_fn, ( & FnSig <' hir>, BodyId ) , ImplItemKind :: Fn ( ty, body) , ( ty, * body) ;
@@ -4958,7 +4974,7 @@ mod size_asserts {
49584974 static_assert_size ! ( GenericBound <' _>, 64 ) ;
49594975 static_assert_size ! ( Generics <' _>, 56 ) ;
49604976 static_assert_size ! ( Impl <' _>, 40 ) ;
4961- static_assert_size ! ( ImplItem <' _>, 96 ) ;
4977+ static_assert_size ! ( ImplItem <' _>, 88 ) ;
49624978 static_assert_size ! ( ImplItemKind <' _>, 40 ) ;
49634979 static_assert_size ! ( Item <' _>, 88 ) ;
49644980 static_assert_size ! ( ItemKind <' _>, 64 ) ;
0 commit comments