@@ -3220,12 +3220,21 @@ pub struct ImplItem<'hir> {
3220
3220
pub owner_id : OwnerId ,
3221
3221
pub generics : & ' hir Generics < ' hir > ,
3222
3222
pub kind : ImplItemKind < ' hir > ,
3223
- pub defaultness : Defaultness ,
3223
+ pub impl_kind : ImplItemImplKind ,
3224
3224
pub span : Span ,
3225
- pub vis_span : Span ,
3226
3225
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
+ } ,
3229
3238
}
3230
3239
3231
3240
impl < ' hir > ImplItem < ' hir > {
@@ -3239,6 +3248,13 @@ impl<'hir> ImplItem<'hir> {
3239
3248
ImplItemId { owner_id : self . owner_id }
3240
3249
}
3241
3250
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
+
3242
3258
expect_methods_self_kind ! {
3243
3259
expect_const, ( & ' hir Ty <' hir>, BodyId ) , ImplItemKind :: Const ( ty, body) , ( ty, * body) ;
3244
3260
expect_fn, ( & FnSig <' hir>, BodyId ) , ImplItemKind :: Fn ( ty, body) , ( ty, * body) ;
@@ -4985,7 +5001,7 @@ mod size_asserts {
4985
5001
static_assert_size ! ( GenericBound <' _>, 64 ) ;
4986
5002
static_assert_size ! ( Generics <' _>, 56 ) ;
4987
5003
static_assert_size ! ( Impl <' _>, 40 ) ;
4988
- static_assert_size ! ( ImplItem <' _>, 96 ) ;
5004
+ static_assert_size ! ( ImplItem <' _>, 88 ) ;
4989
5005
static_assert_size ! ( ImplItemKind <' _>, 40 ) ;
4990
5006
static_assert_size ! ( Item <' _>, 88 ) ;
4991
5007
static_assert_size ! ( ItemKind <' _>, 64 ) ;
0 commit comments