@@ -3190,12 +3190,22 @@ pub struct ImplItem<'hir> {
3190
3190
pub owner_id : OwnerId ,
3191
3191
pub generics : & ' hir Generics < ' hir > ,
3192
3192
pub kind : ImplItemKind < ' hir > ,
3193
- pub defaultness : Defaultness ,
3193
+ pub impl_kind : ImplItemImplKind ,
3194
3194
pub span : Span ,
3195
- pub vis_span : Span ,
3196
3195
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
+ } ,
3199
3209
}
3200
3210
3201
3211
impl < ' hir > ImplItem < ' hir > {
@@ -3209,6 +3219,13 @@ impl<'hir> ImplItem<'hir> {
3209
3219
ImplItemId { owner_id : self . owner_id }
3210
3220
}
3211
3221
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
+
3212
3229
expect_methods_self_kind ! {
3213
3230
expect_const, ( & ' hir Ty <' hir>, BodyId ) , ImplItemKind :: Const ( ty, body) , ( ty, * body) ;
3214
3231
expect_fn, ( & FnSig <' hir>, BodyId ) , ImplItemKind :: Fn ( ty, body) , ( ty, * body) ;
@@ -4953,7 +4970,7 @@ mod size_asserts {
4953
4970
static_assert_size ! ( GenericBound <' _>, 64 ) ;
4954
4971
static_assert_size ! ( Generics <' _>, 56 ) ;
4955
4972
static_assert_size ! ( Impl <' _>, 80 ) ;
4956
- static_assert_size ! ( ImplItem <' _>, 96 ) ;
4973
+ static_assert_size ! ( ImplItem <' _>, 88 ) ;
4957
4974
static_assert_size ! ( ImplItemKind <' _>, 40 ) ;
4958
4975
static_assert_size ! ( Item <' _>, 88 ) ;
4959
4976
static_assert_size ! ( ItemKind <' _>, 64 ) ;
0 commit comments