@@ -3220,12 +3220,21 @@ pub struct ImplItem<'hir> {
32203220 pub owner_id : OwnerId ,
32213221 pub generics : & ' hir Generics < ' hir > ,
32223222 pub kind : ImplItemKind < ' hir > ,
3223- pub defaultness : Defaultness ,
3223+ pub impl_kind : ImplItemImplKind ,
32243224 pub span : Span ,
3225- pub vis_span : Span ,
32263225 pub has_delayed_lints : bool ,
3227- /// When we are in a trait impl, link to the trait-item's id.
3228- pub trait_item_def_id : Option < DefId > ,
3226+ }
3227+
3228+ #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
3229+ pub enum ImplItemImplKind {
3230+ Inherent {
3231+ vis_span : Span ,
3232+ } ,
3233+ Trait {
3234+ defaultness : Defaultness ,
3235+ /// Item in the trait that this item implements
3236+ trait_item_def_id : Result < DefId , ErrorGuaranteed > ,
3237+ } ,
32293238}
32303239
32313240impl < ' hir > ImplItem < ' hir > {
@@ -3239,6 +3248,13 @@ impl<'hir> ImplItem<'hir> {
32393248 ImplItemId { owner_id : self . owner_id }
32403249 }
32413250
3251+ pub fn vis_span ( & self ) -> Option < Span > {
3252+ match self . impl_kind {
3253+ ImplItemImplKind :: Trait { .. } => None ,
3254+ ImplItemImplKind :: Inherent { vis_span, .. } => Some ( vis_span) ,
3255+ }
3256+ }
3257+
32423258 expect_methods_self_kind ! {
32433259 expect_const, ( & ' hir Ty <' hir>, BodyId ) , ImplItemKind :: Const ( ty, body) , ( ty, * body) ;
32443260 expect_fn, ( & FnSig <' hir>, BodyId ) , ImplItemKind :: Fn ( ty, body) , ( ty, * body) ;
@@ -4985,7 +5001,7 @@ mod size_asserts {
49855001 static_assert_size ! ( GenericBound <' _>, 64 ) ;
49865002 static_assert_size ! ( Generics <' _>, 56 ) ;
49875003 static_assert_size ! ( Impl <' _>, 40 ) ;
4988- static_assert_size ! ( ImplItem <' _>, 96 ) ;
5004+ static_assert_size ! ( ImplItem <' _>, 88 ) ;
49895005 static_assert_size ! ( ImplItemKind <' _>, 40 ) ;
49905006 static_assert_size ! ( Item <' _>, 88 ) ;
49915007 static_assert_size ! ( ItemKind <' _>, 64 ) ;
0 commit comments