@@ -2655,6 +2655,36 @@ impl Default for FnHeader {
2655
2655
}
2656
2656
}
2657
2657
2658
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2659
+ pub struct TraitKind (
2660
+ pub IsAuto ,
2661
+ pub Unsafe ,
2662
+ pub Generics ,
2663
+ pub GenericBounds ,
2664
+ pub Vec < P < AssocItem > > ,
2665
+ ) ;
2666
+
2667
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2668
+ pub struct TyAliasKind ( pub Defaultness , pub Generics , pub GenericBounds , pub Option < P < Ty > > ) ;
2669
+
2670
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2671
+ pub struct ImplKind {
2672
+ pub unsafety : Unsafe ,
2673
+ pub polarity : ImplPolarity ,
2674
+ pub defaultness : Defaultness ,
2675
+ pub constness : Const ,
2676
+ pub generics : Generics ,
2677
+
2678
+ /// The trait being implemented, if any.
2679
+ pub of_trait : Option < TraitRef > ,
2680
+
2681
+ pub self_ty : P < Ty > ,
2682
+ pub items : Vec < P < AssocItem > > ,
2683
+ }
2684
+
2685
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2686
+ pub struct FnKind ( pub Defaultness , pub FnSig , pub Generics , pub Option < P < Block > > ) ;
2687
+
2658
2688
#[ derive( Clone , Encodable , Decodable , Debug ) ]
2659
2689
pub enum ItemKind {
2660
2690
/// An `extern crate` item, with the optional *original* crate name if the crate was renamed.
@@ -2676,7 +2706,7 @@ pub enum ItemKind {
2676
2706
/// A function declaration (`fn`).
2677
2707
///
2678
2708
/// E.g., `fn foo(bar: usize) -> usize { .. }`.
2679
- Fn ( Defaultness , FnSig , Generics , Option < P < Block > > ) ,
2709
+ Fn ( Box < FnKind > ) ,
2680
2710
/// A module declaration (`mod`).
2681
2711
///
2682
2712
/// E.g., `mod foo;` or `mod foo { .. }`.
@@ -2690,7 +2720,7 @@ pub enum ItemKind {
2690
2720
/// A type alias (`type`).
2691
2721
///
2692
2722
/// E.g., `type Foo = Bar<u8>;`.
2693
- TyAlias ( Defaultness , Generics , GenericBounds , Option < P < Ty > > ) ,
2723
+ TyAlias ( Box < TyAliasKind > ) ,
2694
2724
/// An enum definition (`enum`).
2695
2725
///
2696
2726
/// E.g., `enum Foo<A, B> { C<A>, D<B> }`.
@@ -2706,27 +2736,15 @@ pub enum ItemKind {
2706
2736
/// A trait declaration (`trait`).
2707
2737
///
2708
2738
/// E.g., `trait Foo { .. }`, `trait Foo<T> { .. }` or `auto trait Foo {}`.
2709
- Trait ( IsAuto , Unsafe , Generics , GenericBounds , Vec < P < AssocItem > > ) ,
2739
+ Trait ( Box < TraitKind > ) ,
2710
2740
/// Trait alias
2711
2741
///
2712
2742
/// E.g., `trait Foo = Bar + Quux;`.
2713
2743
TraitAlias ( Generics , GenericBounds ) ,
2714
2744
/// An implementation.
2715
2745
///
2716
2746
/// E.g., `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`.
2717
- Impl {
2718
- unsafety : Unsafe ,
2719
- polarity : ImplPolarity ,
2720
- defaultness : Defaultness ,
2721
- constness : Const ,
2722
- generics : Generics ,
2723
-
2724
- /// The trait being implemented, if any.
2725
- of_trait : Option < TraitRef > ,
2726
-
2727
- self_ty : P < Ty > ,
2728
- items : Vec < P < AssocItem > > ,
2729
- } ,
2747
+ Impl ( Box < ImplKind > ) ,
2730
2748
/// A macro invocation.
2731
2749
///
2732
2750
/// E.g., `foo!(..)`.
@@ -2736,6 +2754,9 @@ pub enum ItemKind {
2736
2754
MacroDef ( MacroDef ) ,
2737
2755
}
2738
2756
2757
+ #[ cfg( target_arch = "x86_64" ) ]
2758
+ rustc_data_structures:: static_assert_size!( ItemKind , 112 ) ;
2759
+
2739
2760
impl ItemKind {
2740
2761
pub fn article ( & self ) -> & str {
2741
2762
use ItemKind :: * ;
@@ -2770,14 +2791,14 @@ impl ItemKind {
2770
2791
2771
2792
pub fn generics ( & self ) -> Option < & Generics > {
2772
2793
match self {
2773
- Self :: Fn ( _, _, generics, _)
2774
- | Self :: TyAlias ( _, generics, ..)
2794
+ Self :: Fn ( box FnKind ( _, _, generics, _) )
2795
+ | Self :: TyAlias ( box TyAliasKind ( _, generics, ..) )
2775
2796
| Self :: Enum ( _, generics)
2776
2797
| Self :: Struct ( _, generics)
2777
2798
| Self :: Union ( _, generics)
2778
- | Self :: Trait ( _, _, generics, ..)
2799
+ | Self :: Trait ( box TraitKind ( _, _, generics, ..) )
2779
2800
| Self :: TraitAlias ( generics, _)
2780
- | Self :: Impl { generics, .. } => Some ( generics) ,
2801
+ | Self :: Impl ( box ImplKind { generics, .. } ) => Some ( generics) ,
2781
2802
_ => None ,
2782
2803
}
2783
2804
}
@@ -2800,17 +2821,22 @@ pub enum AssocItemKind {
2800
2821
/// If `def` is parsed, then the constant is provided, and otherwise required.
2801
2822
Const ( Defaultness , P < Ty > , Option < P < Expr > > ) ,
2802
2823
/// An associated function.
2803
- Fn ( Defaultness , FnSig , Generics , Option < P < Block > > ) ,
2824
+ Fn ( Box < FnKind > ) ,
2804
2825
/// An associated type.
2805
- TyAlias ( Defaultness , Generics , GenericBounds , Option < P < Ty > > ) ,
2826
+ TyAlias ( Box < TyAliasKind > ) ,
2806
2827
/// A macro expanding to associated items.
2807
2828
MacCall ( MacCall ) ,
2808
2829
}
2809
2830
2831
+ #[ cfg( target_arch = "x86_64" ) ]
2832
+ rustc_data_structures:: static_assert_size!( AssocItemKind , 72 ) ;
2833
+
2810
2834
impl AssocItemKind {
2811
2835
pub fn defaultness ( & self ) -> Defaultness {
2812
2836
match * self {
2813
- Self :: Const ( def, ..) | Self :: Fn ( def, ..) | Self :: TyAlias ( def, ..) => def,
2837
+ Self :: Const ( def, ..)
2838
+ | Self :: Fn ( box FnKind ( def, ..) )
2839
+ | Self :: TyAlias ( box TyAliasKind ( def, ..) ) => def,
2814
2840
Self :: MacCall ( ..) => Defaultness :: Final ,
2815
2841
}
2816
2842
}
@@ -2820,8 +2846,8 @@ impl From<AssocItemKind> for ItemKind {
2820
2846
fn from ( assoc_item_kind : AssocItemKind ) -> ItemKind {
2821
2847
match assoc_item_kind {
2822
2848
AssocItemKind :: Const ( a, b, c) => ItemKind :: Const ( a, b, c) ,
2823
- AssocItemKind :: Fn ( a , b , c , d ) => ItemKind :: Fn ( a , b , c , d ) ,
2824
- AssocItemKind :: TyAlias ( a , b , c , d ) => ItemKind :: TyAlias ( a , b , c , d ) ,
2849
+ AssocItemKind :: Fn ( fn_kind ) => ItemKind :: Fn ( fn_kind ) ,
2850
+ AssocItemKind :: TyAlias ( ty_alias_kind ) => ItemKind :: TyAlias ( ty_alias_kind ) ,
2825
2851
AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
2826
2852
}
2827
2853
}
@@ -2833,8 +2859,8 @@ impl TryFrom<ItemKind> for AssocItemKind {
2833
2859
fn try_from ( item_kind : ItemKind ) -> Result < AssocItemKind , ItemKind > {
2834
2860
Ok ( match item_kind {
2835
2861
ItemKind :: Const ( a, b, c) => AssocItemKind :: Const ( a, b, c) ,
2836
- ItemKind :: Fn ( a , b , c , d ) => AssocItemKind :: Fn ( a , b , c , d ) ,
2837
- ItemKind :: TyAlias ( a , b , c , d ) => AssocItemKind :: TyAlias ( a , b , c , d ) ,
2862
+ ItemKind :: Fn ( fn_kind ) => AssocItemKind :: Fn ( fn_kind ) ,
2863
+ ItemKind :: TyAlias ( ty_alias_kind ) => AssocItemKind :: TyAlias ( ty_alias_kind ) ,
2838
2864
ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
2839
2865
_ => return Err ( item_kind) ,
2840
2866
} )
@@ -2846,20 +2872,23 @@ impl TryFrom<ItemKind> for AssocItemKind {
2846
2872
pub enum ForeignItemKind {
2847
2873
/// A foreign static item (`static FOO: u8`).
2848
2874
Static ( P < Ty > , Mutability , Option < P < Expr > > ) ,
2849
- /// A foreign function.
2850
- Fn ( Defaultness , FnSig , Generics , Option < P < Block > > ) ,
2851
- /// A foreign type.
2852
- TyAlias ( Defaultness , Generics , GenericBounds , Option < P < Ty > > ) ,
2875
+ /// An foreign function.
2876
+ Fn ( Box < FnKind > ) ,
2877
+ /// An foreign type.
2878
+ TyAlias ( Box < TyAliasKind > ) ,
2853
2879
/// A macro expanding to foreign items.
2854
2880
MacCall ( MacCall ) ,
2855
2881
}
2856
2882
2883
+ #[ cfg( target_arch = "x86_64" ) ]
2884
+ rustc_data_structures:: static_assert_size!( ForeignItemKind , 72 ) ;
2885
+
2857
2886
impl From < ForeignItemKind > for ItemKind {
2858
2887
fn from ( foreign_item_kind : ForeignItemKind ) -> ItemKind {
2859
2888
match foreign_item_kind {
2860
2889
ForeignItemKind :: Static ( a, b, c) => ItemKind :: Static ( a, b, c) ,
2861
- ForeignItemKind :: Fn ( a , b , c , d ) => ItemKind :: Fn ( a , b , c , d ) ,
2862
- ForeignItemKind :: TyAlias ( a , b , c , d ) => ItemKind :: TyAlias ( a , b , c , d ) ,
2890
+ ForeignItemKind :: Fn ( fn_kind ) => ItemKind :: Fn ( fn_kind ) ,
2891
+ ForeignItemKind :: TyAlias ( ty_alias_kind ) => ItemKind :: TyAlias ( ty_alias_kind ) ,
2863
2892
ForeignItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
2864
2893
}
2865
2894
}
@@ -2871,8 +2900,8 @@ impl TryFrom<ItemKind> for ForeignItemKind {
2871
2900
fn try_from ( item_kind : ItemKind ) -> Result < ForeignItemKind , ItemKind > {
2872
2901
Ok ( match item_kind {
2873
2902
ItemKind :: Static ( a, b, c) => ForeignItemKind :: Static ( a, b, c) ,
2874
- ItemKind :: Fn ( a , b , c , d ) => ForeignItemKind :: Fn ( a , b , c , d ) ,
2875
- ItemKind :: TyAlias ( a , b , c , d ) => ForeignItemKind :: TyAlias ( a , b , c , d ) ,
2903
+ ItemKind :: Fn ( fn_kind ) => ForeignItemKind :: Fn ( fn_kind ) ,
2904
+ ItemKind :: TyAlias ( ty_alias_kind ) => ForeignItemKind :: TyAlias ( ty_alias_kind ) ,
2876
2905
ItemKind :: MacCall ( a) => ForeignItemKind :: MacCall ( a) ,
2877
2906
_ => return Err ( item_kind) ,
2878
2907
} )
0 commit comments