@@ -3208,12 +3208,21 @@ pub struct ImplItem<'hir> {
32083208 pub owner_id : OwnerId ,
32093209 pub generics : & ' hir Generics < ' hir > ,
32103210 pub kind : ImplItemKind < ' hir > ,
3211- pub defaultness : Defaultness ,
3211+ pub impl_kind : ImplItemImplKind ,
32123212 pub span : Span ,
3213- pub vis_span : Span ,
32143213 pub has_delayed_lints : bool ,
3215- /// When we are in a trait impl, link to the trait-item's id.
3216- pub trait_item_def_id : Option < DefId > ,
3214+ }
3215+
3216+ #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
3217+ pub enum ImplItemImplKind {
3218+ Inherent {
3219+ vis_span : Span ,
3220+ } ,
3221+ Trait {
3222+ defaultness : Defaultness ,
3223+ /// Item in the trait that this item implements
3224+ trait_item_def_id : Result < DefId , ErrorGuaranteed > ,
3225+ } ,
32173226}
32183227
32193228impl < ' hir > ImplItem < ' hir > {
@@ -3227,6 +3236,13 @@ impl<'hir> ImplItem<'hir> {
32273236 ImplItemId { owner_id : self . owner_id }
32283237 }
32293238
3239+ pub fn vis_span ( & self ) -> Option < Span > {
3240+ match self . impl_kind {
3241+ ImplItemImplKind :: Trait { .. } => None ,
3242+ ImplItemImplKind :: Inherent { vis_span, .. } => Some ( vis_span) ,
3243+ }
3244+ }
3245+
32303246 expect_methods_self_kind ! {
32313247 expect_const, ( & ' hir Ty <' hir>, BodyId ) , ImplItemKind :: Const ( ty, body) , ( ty, * body) ;
32323248 expect_fn, ( & FnSig <' hir>, BodyId ) , ImplItemKind :: Fn ( ty, body) , ( ty, * body) ;
@@ -4973,7 +4989,7 @@ mod size_asserts {
49734989 static_assert_size ! ( GenericBound <' _>, 64 ) ;
49744990 static_assert_size ! ( Generics <' _>, 56 ) ;
49754991 static_assert_size ! ( Impl <' _>, 40 ) ;
4976- static_assert_size ! ( ImplItem <' _>, 96 ) ;
4992+ static_assert_size ! ( ImplItem <' _>, 88 ) ;
49774993 static_assert_size ! ( ImplItemKind <' _>, 40 ) ;
49784994 static_assert_size ! ( Item <' _>, 88 ) ;
49794995 static_assert_size ! ( ItemKind <' _>, 64 ) ;
0 commit comments