@@ -3208,12 +3208,21 @@ pub struct ImplItem<'hir> {
3208
3208
pub owner_id : OwnerId ,
3209
3209
pub generics : & ' hir Generics < ' hir > ,
3210
3210
pub kind : ImplItemKind < ' hir > ,
3211
- pub defaultness : Defaultness ,
3211
+ pub impl_kind : ImplItemImplKind ,
3212
3212
pub span : Span ,
3213
- pub vis_span : Span ,
3214
3213
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
+ } ,
3217
3226
}
3218
3227
3219
3228
impl < ' hir > ImplItem < ' hir > {
@@ -3227,6 +3236,13 @@ impl<'hir> ImplItem<'hir> {
3227
3236
ImplItemId { owner_id : self . owner_id }
3228
3237
}
3229
3238
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
+
3230
3246
expect_methods_self_kind ! {
3231
3247
expect_const, ( & ' hir Ty <' hir>, BodyId ) , ImplItemKind :: Const ( ty, body) , ( ty, * body) ;
3232
3248
expect_fn, ( & FnSig <' hir>, BodyId ) , ImplItemKind :: Fn ( ty, body) , ( ty, * body) ;
@@ -4973,7 +4989,7 @@ mod size_asserts {
4973
4989
static_assert_size ! ( GenericBound <' _>, 64 ) ;
4974
4990
static_assert_size ! ( Generics <' _>, 56 ) ;
4975
4991
static_assert_size ! ( Impl <' _>, 40 ) ;
4976
- static_assert_size ! ( ImplItem <' _>, 96 ) ;
4992
+ static_assert_size ! ( ImplItem <' _>, 88 ) ;
4977
4993
static_assert_size ! ( ImplItemKind <' _>, 40 ) ;
4978
4994
static_assert_size ! ( Item <' _>, 88 ) ;
4979
4995
static_assert_size ! ( ItemKind <' _>, 64 ) ;
0 commit comments