@@ -2890,6 +2890,20 @@ pub struct Fn {
28902890 pub body : Option < P < Block > > ,
28912891}
28922892
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+
28932907#[ derive( Clone , Encodable , Decodable , Debug ) ]
28942908pub enum ItemKind {
28952909 /// An `extern crate` item, with the optional *original* crate name if the crate was renamed.
@@ -2903,11 +2917,11 @@ pub enum ItemKind {
29032917 /// A static item (`static`).
29042918 ///
29052919 /// E.g., `static FOO: i32 = 42;` or `static FOO: &'static str = "bar";`.
2906- Static ( P < Ty > , Mutability , Option < P < Expr > > ) ,
2920+ Static ( Box < StaticItem > ) ,
29072921 /// A constant item (`const`).
29082922 ///
29092923 /// E.g., `const FOO: i32 = 42;`.
2910- Const ( Defaultness , P < Ty > , Option < P < Expr > > ) ,
2924+ Const ( Box < ConstItem > ) ,
29112925 /// A function declaration (`fn`).
29122926 ///
29132927 /// E.g., `fn foo(bar: usize) -> usize { .. }`.
@@ -3023,7 +3037,7 @@ pub type AssocItem = Item<AssocItemKind>;
30233037pub enum AssocItemKind {
30243038 /// An associated constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
30253039 /// If `def` is parsed, then the constant is provided, and otherwise required.
3026- Const ( Defaultness , P < Ty > , Option < P < Expr > > ) ,
3040+ Const ( Box < ConstItem > ) ,
30273041 /// An associated function.
30283042 Fn ( Box < Fn > ) ,
30293043 /// An associated type.
@@ -3035,7 +3049,7 @@ pub enum AssocItemKind {
30353049impl AssocItemKind {
30363050 pub fn defaultness ( & self ) -> Defaultness {
30373051 match * self {
3038- Self :: Const ( defaultness, ..)
3052+ Self :: Const ( box ConstItem { defaultness, .. } )
30393053 | Self :: Fn ( box Fn { defaultness, .. } )
30403054 | Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
30413055 Self :: MacCall ( ..) => Defaultness :: Final ,
@@ -3046,7 +3060,7 @@ impl AssocItemKind {
30463060impl From < AssocItemKind > for ItemKind {
30473061 fn from ( assoc_item_kind : AssocItemKind ) -> ItemKind {
30483062 match assoc_item_kind {
3049- AssocItemKind :: Const ( a , b , c ) => ItemKind :: Const ( a , b , c ) ,
3063+ AssocItemKind :: Const ( item ) => ItemKind :: Const ( item ) ,
30503064 AssocItemKind :: Fn ( fn_kind) => ItemKind :: Fn ( fn_kind) ,
30513065 AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
30523066 AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
@@ -3059,7 +3073,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
30593073
30603074 fn try_from ( item_kind : ItemKind ) -> Result < AssocItemKind , ItemKind > {
30613075 Ok ( match item_kind {
3062- ItemKind :: Const ( a , b , c ) => AssocItemKind :: Const ( a , b , c ) ,
3076+ ItemKind :: Const ( item ) => AssocItemKind :: Const ( item ) ,
30633077 ItemKind :: Fn ( fn_kind) => AssocItemKind :: Fn ( fn_kind) ,
30643078 ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
30653079 ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
@@ -3084,7 +3098,9 @@ pub enum ForeignItemKind {
30843098impl From < ForeignItemKind > for ItemKind {
30853099 fn from ( foreign_item_kind : ForeignItemKind ) -> ItemKind {
30863100 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+ }
30883104 ForeignItemKind :: Fn ( fn_kind) => ItemKind :: Fn ( fn_kind) ,
30893105 ForeignItemKind :: TyAlias ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
30903106 ForeignItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
@@ -3097,7 +3113,9 @@ impl TryFrom<ItemKind> for ForeignItemKind {
30973113
30983114 fn try_from ( item_kind : ItemKind ) -> Result < ForeignItemKind , ItemKind > {
30993115 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+ }
31013119 ItemKind :: Fn ( fn_kind) => ForeignItemKind :: Fn ( fn_kind) ,
31023120 ItemKind :: TyAlias ( ty_alias_kind) => ForeignItemKind :: TyAlias ( ty_alias_kind) ,
31033121 ItemKind :: MacCall ( a) => ForeignItemKind :: MacCall ( a) ,
@@ -3114,8 +3132,8 @@ mod size_asserts {
31143132 use super :: * ;
31153133 use rustc_data_structures:: static_assert_size;
31163134 // 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 ) ;
31193137 static_assert_size ! ( Attribute , 32 ) ;
31203138 static_assert_size ! ( Block , 32 ) ;
31213139 static_assert_size ! ( Expr , 72 ) ;
0 commit comments