@@ -2890,6 +2890,20 @@ pub struct Fn {
2890
2890
pub body : Option < P < Block > > ,
2891
2891
}
2892
2892
2893
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2894
+ pub struct StaticItem {
2895
+ pub ty : P < Ty > ,
2896
+ pub mutability : Mutability ,
2897
+ pub expr : Option < P < Expr > > ,
2898
+ }
2899
+
2900
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2901
+ pub struct ConstItem {
2902
+ pub defaultness : Defaultness ,
2903
+ pub ty : P < Ty > ,
2904
+ pub expr : Option < P < Expr > > ,
2905
+ }
2906
+
2893
2907
#[ derive( Clone , Encodable , Decodable , Debug ) ]
2894
2908
pub enum ItemKind {
2895
2909
/// An `extern crate` item, with the optional *original* crate name if the crate was renamed.
@@ -2903,11 +2917,11 @@ pub enum ItemKind {
2903
2917
/// A static item (`static`).
2904
2918
///
2905
2919
/// E.g., `static FOO: i32 = 42;` or `static FOO: &'static str = "bar";`.
2906
- Static ( P < Ty > , Mutability , Option < P < Expr > > ) ,
2920
+ Static ( Box < StaticItem > ) ,
2907
2921
/// A constant item (`const`).
2908
2922
///
2909
2923
/// E.g., `const FOO: i32 = 42;`.
2910
- Const ( Defaultness , P < Ty > , Option < P < Expr > > ) ,
2924
+ Const ( Box < ConstItem > ) ,
2911
2925
/// A function declaration (`fn`).
2912
2926
///
2913
2927
/// E.g., `fn foo(bar: usize) -> usize { .. }`.
@@ -3023,7 +3037,7 @@ pub type AssocItem = Item<AssocItemKind>;
3023
3037
pub enum AssocItemKind {
3024
3038
/// An associated constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
3025
3039
/// If `def` is parsed, then the constant is provided, and otherwise required.
3026
- Const ( Defaultness , P < Ty > , Option < P < Expr > > ) ,
3040
+ Const ( Box < ConstItem > ) ,
3027
3041
/// An associated function.
3028
3042
Fn ( Box < Fn > ) ,
3029
3043
/// An associated type.
@@ -3035,7 +3049,7 @@ pub enum AssocItemKind {
3035
3049
impl AssocItemKind {
3036
3050
pub fn defaultness ( & self ) -> Defaultness {
3037
3051
match * self {
3038
- Self :: Const ( defaultness, ..)
3052
+ Self :: Const ( box ConstItem { defaultness, .. } )
3039
3053
| Self :: Fn ( box Fn { defaultness, .. } )
3040
3054
| Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
3041
3055
Self :: MacCall ( ..) => Defaultness :: Final ,
@@ -3046,7 +3060,7 @@ impl AssocItemKind {
3046
3060
impl From < AssocItemKind > for ItemKind {
3047
3061
fn from ( assoc_item_kind : AssocItemKind ) -> ItemKind {
3048
3062
match assoc_item_kind {
3049
- AssocItemKind :: Const ( a , b , c ) => ItemKind :: Const ( a , b , c ) ,
3063
+ AssocItemKind :: Const ( item ) => ItemKind :: Const ( item ) ,
3050
3064
AssocItemKind :: Fn ( fn_kind) => ItemKind :: Fn ( fn_kind) ,
3051
3065
AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
3052
3066
AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
@@ -3059,7 +3073,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
3059
3073
3060
3074
fn try_from ( item_kind : ItemKind ) -> Result < AssocItemKind , ItemKind > {
3061
3075
Ok ( match item_kind {
3062
- ItemKind :: Const ( a , b , c ) => AssocItemKind :: Const ( a , b , c ) ,
3076
+ ItemKind :: Const ( item ) => AssocItemKind :: Const ( item ) ,
3063
3077
ItemKind :: Fn ( fn_kind) => AssocItemKind :: Fn ( fn_kind) ,
3064
3078
ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
3065
3079
ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
@@ -3084,7 +3098,9 @@ pub enum ForeignItemKind {
3084
3098
impl From < ForeignItemKind > for ItemKind {
3085
3099
fn from ( foreign_item_kind : ForeignItemKind ) -> ItemKind {
3086
3100
match foreign_item_kind {
3087
- ForeignItemKind :: Static ( a, b, c) => ItemKind :: Static ( a, b, c) ,
3101
+ ForeignItemKind :: Static ( a, b, c) => {
3102
+ ItemKind :: Static ( StaticItem { ty : a, mutability : b, expr : c } . into ( ) )
3103
+ }
3088
3104
ForeignItemKind :: Fn ( fn_kind) => ItemKind :: Fn ( fn_kind) ,
3089
3105
ForeignItemKind :: TyAlias ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
3090
3106
ForeignItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
@@ -3097,7 +3113,9 @@ impl TryFrom<ItemKind> for ForeignItemKind {
3097
3113
3098
3114
fn try_from ( item_kind : ItemKind ) -> Result < ForeignItemKind , ItemKind > {
3099
3115
Ok ( match item_kind {
3100
- ItemKind :: Static ( a, b, c) => ForeignItemKind :: Static ( a, b, c) ,
3116
+ ItemKind :: Static ( box StaticItem { ty : a, mutability : b, expr : c } ) => {
3117
+ ForeignItemKind :: Static ( a, b, c)
3118
+ }
3101
3119
ItemKind :: Fn ( fn_kind) => ForeignItemKind :: Fn ( fn_kind) ,
3102
3120
ItemKind :: TyAlias ( ty_alias_kind) => ForeignItemKind :: TyAlias ( ty_alias_kind) ,
3103
3121
ItemKind :: MacCall ( a) => ForeignItemKind :: MacCall ( a) ,
@@ -3114,8 +3132,8 @@ mod size_asserts {
3114
3132
use super :: * ;
3115
3133
use rustc_data_structures:: static_assert_size;
3116
3134
// tidy-alphabetical-start
3117
- static_assert_size ! ( AssocItem , 104 ) ;
3118
- static_assert_size ! ( AssocItemKind , 32 ) ;
3135
+ static_assert_size ! ( AssocItem , 88 ) ;
3136
+ static_assert_size ! ( AssocItemKind , 16 ) ;
3119
3137
static_assert_size ! ( Attribute , 32 ) ;
3120
3138
static_assert_size ! ( Block , 32 ) ;
3121
3139
static_assert_size ! ( Expr , 72 ) ;
0 commit comments