@@ -2897,6 +2897,13 @@ pub struct Static {
2897
2897
pub expr : Option < P < Expr > > ,
2898
2898
}
2899
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
+
2900
2907
#[ derive( Clone , Encodable , Decodable , Debug ) ]
2901
2908
pub enum ItemKind {
2902
2909
/// An `extern crate` item, with the optional *original* crate name if the crate was renamed.
@@ -2914,7 +2921,7 @@ pub enum ItemKind {
2914
2921
/// A constant item (`const`).
2915
2922
///
2916
2923
/// E.g., `const FOO: i32 = 42;`.
2917
- Const ( Defaultness , P < Ty > , Option < P < Expr > > ) ,
2924
+ Const ( ConstItem ) ,
2918
2925
/// A function declaration (`fn`).
2919
2926
///
2920
2927
/// E.g., `fn foo(bar: usize) -> usize { .. }`.
@@ -3030,7 +3037,7 @@ pub type AssocItem = Item<AssocItemKind>;
3030
3037
pub enum AssocItemKind {
3031
3038
/// An associated constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
3032
3039
/// If `def` is parsed, then the constant is provided, and otherwise required.
3033
- Const ( Defaultness , P < Ty > , Option < P < Expr > > ) ,
3040
+ Const ( ConstItem ) ,
3034
3041
/// An associated function.
3035
3042
Fn ( Box < Fn > ) ,
3036
3043
/// An associated type.
@@ -3042,7 +3049,7 @@ pub enum AssocItemKind {
3042
3049
impl AssocItemKind {
3043
3050
pub fn defaultness ( & self ) -> Defaultness {
3044
3051
match * self {
3045
- Self :: Const ( defaultness, ..)
3052
+ Self :: Const ( ConstItem { defaultness, .. } )
3046
3053
| Self :: Fn ( box Fn { defaultness, .. } )
3047
3054
| Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
3048
3055
Self :: MacCall ( ..) => Defaultness :: Final ,
@@ -3053,7 +3060,7 @@ impl AssocItemKind {
3053
3060
impl From < AssocItemKind > for ItemKind {
3054
3061
fn from ( assoc_item_kind : AssocItemKind ) -> ItemKind {
3055
3062
match assoc_item_kind {
3056
- AssocItemKind :: Const ( a , b , c ) => ItemKind :: Const ( a , b , c ) ,
3063
+ AssocItemKind :: Const ( item ) => ItemKind :: Const ( item ) ,
3057
3064
AssocItemKind :: Fn ( fn_kind) => ItemKind :: Fn ( fn_kind) ,
3058
3065
AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
3059
3066
AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
@@ -3066,7 +3073,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
3066
3073
3067
3074
fn try_from ( item_kind : ItemKind ) -> Result < AssocItemKind , ItemKind > {
3068
3075
Ok ( match item_kind {
3069
- ItemKind :: Const ( a , b , c ) => AssocItemKind :: Const ( a , b , c ) ,
3076
+ ItemKind :: Const ( item ) => AssocItemKind :: Const ( item ) ,
3070
3077
ItemKind :: Fn ( fn_kind) => AssocItemKind :: Fn ( fn_kind) ,
3071
3078
ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
3072
3079
ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
0 commit comments