@@ -3190,12 +3190,22 @@ pub struct ImplItem<'hir> {
31903190 pub owner_id : OwnerId ,
31913191 pub generics : & ' hir Generics < ' hir > ,
31923192 pub kind : ImplItemKind < ' hir > ,
3193- pub defaultness : Defaultness ,
3193+ pub impl_kind : ImplItemImplKind ,
31943194 pub span : Span ,
3195- pub vis_span : Span ,
31963195 pub has_delayed_lints : bool ,
3197- /// When we are in a trait impl, link to the trait-item's id.
3198- pub trait_item_def_id : Option < DefId > ,
3196+ }
3197+
3198+ #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
3199+ pub enum ImplItemImplKind {
3200+ Inherent {
3201+ vis_span : Span ,
3202+ } ,
3203+ Trait {
3204+ defaultness : Defaultness ,
3205+ /// Item in the trait that this item implements.
3206+ /// May be `None` if there is an error.
3207+ trait_item_def_id : Option < DefId > ,
3208+ } ,
31993209}
32003210
32013211impl < ' hir > ImplItem < ' hir > {
@@ -3209,6 +3219,13 @@ impl<'hir> ImplItem<'hir> {
32093219 ImplItemId { owner_id : self . owner_id }
32103220 }
32113221
3222+ pub fn vis_span ( & self ) -> Option < Span > {
3223+ match self . impl_kind {
3224+ ImplItemImplKind :: Trait { .. } => None ,
3225+ ImplItemImplKind :: Inherent { vis_span, .. } => Some ( vis_span) ,
3226+ }
3227+ }
3228+
32123229 expect_methods_self_kind ! {
32133230 expect_const, ( & ' hir Ty <' hir>, BodyId ) , ImplItemKind :: Const ( ty, body) , ( ty, * body) ;
32143231 expect_fn, ( & FnSig <' hir>, BodyId ) , ImplItemKind :: Fn ( ty, body) , ( ty, * body) ;
@@ -4953,7 +4970,7 @@ mod size_asserts {
49534970 static_assert_size ! ( GenericBound <' _>, 64 ) ;
49544971 static_assert_size ! ( Generics <' _>, 56 ) ;
49554972 static_assert_size ! ( Impl <' _>, 80 ) ;
4956- static_assert_size ! ( ImplItem <' _>, 96 ) ;
4973+ static_assert_size ! ( ImplItem <' _>, 88 ) ;
49574974 static_assert_size ! ( ImplItemKind <' _>, 40 ) ;
49584975 static_assert_size ! ( Item <' _>, 88 ) ;
49594976 static_assert_size ! ( ItemKind <' _>, 64 ) ;
0 commit comments