@@ -487,6 +487,7 @@ pub enum GenericParamKind<'hir> {
487
487
#[ derive( Debug , HashStable_Generic ) ]
488
488
pub struct GenericParam < ' hir > {
489
489
pub hir_id : HirId ,
490
+ pub def_id : LocalDefId ,
490
491
pub name : ParamName ,
491
492
pub span : Span ,
492
493
pub pure_wrt_drop : bool ,
@@ -921,6 +922,7 @@ pub struct Crate<'hir> {
921
922
922
923
#[ derive( Debug , HashStable_Generic ) ]
923
924
pub struct Closure < ' hir > {
925
+ pub def_id : LocalDefId ,
924
926
pub binder : ClosureBinder ,
925
927
pub capture_clause : CaptureBy ,
926
928
pub bound_generic_params : & ' hir [ GenericParam < ' hir > ] ,
@@ -1615,7 +1617,7 @@ pub enum ArrayLen {
1615
1617
impl ArrayLen {
1616
1618
pub fn hir_id ( & self ) -> HirId {
1617
1619
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,
1619
1621
}
1620
1622
}
1621
1623
}
@@ -1627,10 +1629,11 @@ impl ArrayLen {
1627
1629
/// explicit discriminant values for enum variants.
1628
1630
///
1629
1631
/// 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 (..)`
1631
1633
#[ derive( Copy , Clone , PartialEq , Eq , Encodable , Debug , HashStable_Generic ) ]
1632
1634
pub struct AnonConst {
1633
1635
pub hir_id : HirId ,
1636
+ pub def_id : LocalDefId ,
1634
1637
pub body : BodyId ,
1635
1638
}
1636
1639
@@ -2798,7 +2801,8 @@ pub struct Variant<'hir> {
2798
2801
/// Name of the variant.
2799
2802
pub ident : Ident ,
2800
2803
/// 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 ,
2802
2806
/// Fields and constructor id of the variant.
2803
2807
pub data : VariantData < ' hir > ,
2804
2808
/// Explicit discriminant (e.g., `Foo = 1`).
@@ -2865,6 +2869,7 @@ pub struct FieldDef<'hir> {
2865
2869
pub vis_span : Span ,
2866
2870
pub ident : Ident ,
2867
2871
pub hir_id : HirId ,
2872
+ pub def_id : LocalDefId ,
2868
2873
pub ty : & ' hir Ty < ' hir > ,
2869
2874
}
2870
2875
@@ -2886,11 +2891,11 @@ pub enum VariantData<'hir> {
2886
2891
/// A tuple variant.
2887
2892
///
2888
2893
/// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`.
2889
- Tuple ( & ' hir [ FieldDef < ' hir > ] , HirId ) ,
2894
+ Tuple ( & ' hir [ FieldDef < ' hir > ] , HirId , LocalDefId ) ,
2890
2895
/// A unit variant.
2891
2896
///
2892
2897
/// E.g., `Bar = ..` as in `enum Foo { Bar = .. }`.
2893
- Unit ( HirId ) ,
2898
+ Unit ( HirId , LocalDefId ) ,
2894
2899
}
2895
2900
2896
2901
impl < ' hir > VariantData < ' hir > {
@@ -2902,11 +2907,19 @@ impl<'hir> VariantData<'hir> {
2902
2907
}
2903
2908
}
2904
2909
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
+
2905
2918
/// Return the `HirId` of this variant's constructor, if it has one.
2906
2919
pub fn ctor_hir_id ( & self ) -> Option < HirId > {
2907
2920
match * self {
2908
2921
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) ,
2910
2923
}
2911
2924
}
2912
2925
}
@@ -3532,7 +3545,7 @@ impl<'hir> Node<'hir> {
3532
3545
/// Get the fields for the tuple-constructor,
3533
3546
/// if this node is a tuple constructor, otherwise None
3534
3547
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 }
3536
3549
}
3537
3550
}
3538
3551
@@ -3548,7 +3561,7 @@ mod size_asserts {
3548
3561
static_assert_size ! ( FnDecl <' _>, 40 ) ;
3549
3562
static_assert_size ! ( ForeignItem <' _>, 72 ) ;
3550
3563
static_assert_size ! ( ForeignItemKind <' _>, 40 ) ;
3551
- static_assert_size ! ( GenericArg <' _>, 24 ) ;
3564
+ static_assert_size ! ( GenericArg <' _>, 32 ) ;
3552
3565
static_assert_size ! ( GenericBound <' _>, 48 ) ;
3553
3566
static_assert_size ! ( Generics <' _>, 56 ) ;
3554
3567
static_assert_size ! ( Impl <' _>, 80 ) ;
0 commit comments