@@ -487,6 +487,7 @@ pub enum GenericParamKind<'hir> {
487487#[ derive( Debug , HashStable_Generic ) ]
488488pub struct GenericParam < ' hir > {
489489 pub hir_id : HirId ,
490+ pub def_id : LocalDefId ,
490491 pub name : ParamName ,
491492 pub span : Span ,
492493 pub pure_wrt_drop : bool ,
@@ -921,6 +922,7 @@ pub struct Crate<'hir> {
921922
922923#[ derive( Debug , HashStable_Generic ) ]
923924pub struct Closure < ' hir > {
925+ pub def_id : LocalDefId ,
924926 pub binder : ClosureBinder ,
925927 pub capture_clause : CaptureBy ,
926928 pub bound_generic_params : & ' hir [ GenericParam < ' hir > ] ,
@@ -1615,7 +1617,7 @@ pub enum ArrayLen {
16151617impl ArrayLen {
16161618 pub fn hir_id ( & self ) -> HirId {
16171619 match self {
1618- & ArrayLen :: Infer ( hir_id, _) | & ArrayLen :: Body ( AnonConst { hir_id, body : _ } ) => hir_id,
1620+ & ArrayLen :: Infer ( hir_id, _) | & ArrayLen :: Body ( AnonConst { hir_id, .. } ) => hir_id,
16191621 }
16201622 }
16211623}
@@ -1627,10 +1629,11 @@ impl ArrayLen {
16271629/// explicit discriminant values for enum variants.
16281630///
16291631/// You can check if this anon const is a default in a const param
1630- /// `const N: usize = { ... }` with `tcx.hir().opt_const_param_default_param_hir_id (..)`
1632+ /// `const N: usize = { ... }` with `tcx.hir().opt_const_param_default_param_def_id (..)`
16311633#[ derive( Copy , Clone , PartialEq , Eq , Encodable , Debug , HashStable_Generic ) ]
16321634pub struct AnonConst {
16331635 pub hir_id : HirId ,
1636+ pub def_id : LocalDefId ,
16341637 pub body : BodyId ,
16351638}
16361639
@@ -2798,7 +2801,8 @@ pub struct Variant<'hir> {
27982801 /// Name of the variant.
27992802 pub ident : Ident ,
28002803 /// Id of the variant (not the constructor, see `VariantData::ctor_hir_id()`).
2801- pub id : HirId ,
2804+ pub hir_id : HirId ,
2805+ pub def_id : LocalDefId ,
28022806 /// Fields and constructor id of the variant.
28032807 pub data : VariantData < ' hir > ,
28042808 /// Explicit discriminant (e.g., `Foo = 1`).
@@ -2865,6 +2869,7 @@ pub struct FieldDef<'hir> {
28652869 pub vis_span : Span ,
28662870 pub ident : Ident ,
28672871 pub hir_id : HirId ,
2872+ pub def_id : LocalDefId ,
28682873 pub ty : & ' hir Ty < ' hir > ,
28692874}
28702875
@@ -2886,11 +2891,11 @@ pub enum VariantData<'hir> {
28862891 /// A tuple variant.
28872892 ///
28882893 /// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`.
2889- Tuple ( & ' hir [ FieldDef < ' hir > ] , HirId ) ,
2894+ Tuple ( & ' hir [ FieldDef < ' hir > ] , HirId , LocalDefId ) ,
28902895 /// A unit variant.
28912896 ///
28922897 /// E.g., `Bar = ..` as in `enum Foo { Bar = .. }`.
2893- Unit ( HirId ) ,
2898+ Unit ( HirId , LocalDefId ) ,
28942899}
28952900
28962901impl < ' hir > VariantData < ' hir > {
@@ -2902,11 +2907,19 @@ impl<'hir> VariantData<'hir> {
29022907 }
29032908 }
29042909
2910+ /// Return the `LocalDefId` of this variant's constructor, if it has one.
2911+ pub fn ctor_def_id ( & self ) -> Option < LocalDefId > {
2912+ match * self {
2913+ VariantData :: Struct ( _, _) => None ,
2914+ VariantData :: Tuple ( _, _, def_id) | VariantData :: Unit ( _, def_id) => Some ( def_id) ,
2915+ }
2916+ }
2917+
29052918 /// Return the `HirId` of this variant's constructor, if it has one.
29062919 pub fn ctor_hir_id ( & self ) -> Option < HirId > {
29072920 match * self {
29082921 VariantData :: Struct ( _, _) => None ,
2909- VariantData :: Tuple ( _, hir_id) | VariantData :: Unit ( hir_id) => Some ( hir_id) ,
2922+ VariantData :: Tuple ( _, hir_id, _ ) | VariantData :: Unit ( hir_id, _ ) => Some ( hir_id) ,
29102923 }
29112924 }
29122925}
@@ -3532,7 +3545,7 @@ impl<'hir> Node<'hir> {
35323545 /// Get the fields for the tuple-constructor,
35333546 /// if this node is a tuple constructor, otherwise None
35343547 pub fn tuple_fields ( & self ) -> Option < & ' hir [ FieldDef < ' hir > ] > {
3535- if let Node :: Ctor ( & VariantData :: Tuple ( fields, _) ) = self { Some ( fields) } else { None }
3548+ if let Node :: Ctor ( & VariantData :: Tuple ( fields, _, _ ) ) = self { Some ( fields) } else { None }
35363549 }
35373550}
35383551
@@ -3548,7 +3561,7 @@ mod size_asserts {
35483561 static_assert_size ! ( FnDecl <' _>, 40 ) ;
35493562 static_assert_size ! ( ForeignItem <' _>, 72 ) ;
35503563 static_assert_size ! ( ForeignItemKind <' _>, 40 ) ;
3551- static_assert_size ! ( GenericArg <' _>, 24 ) ;
3564+ static_assert_size ! ( GenericArg <' _>, 32 ) ;
35523565 static_assert_size ! ( GenericBound <' _>, 48 ) ;
35533566 static_assert_size ! ( Generics <' _>, 56 ) ;
35543567 static_assert_size ! ( Impl <' _>, 80 ) ;
0 commit comments