@@ -2441,10 +2441,10 @@ impl Item {
24412441 }
24422442}
24432443
2444- impl < K : IntoItemKind > Item < K > {
2444+ impl < K : Into < ItemKind > > Item < K > {
24452445 pub fn into_item ( self ) -> Item {
24462446 let Item { attrs, id, span, vis, ident, kind, tokens } = self ;
2447- Item { attrs, id, span, vis, ident, kind : kind. into_item_kind ( ) , tokens }
2447+ Item { attrs, id, span, vis, ident, kind : kind. into ( ) , tokens }
24482448 }
24492449}
24502450
@@ -2624,20 +2624,11 @@ impl ItemKind {
26242624 }
26252625}
26262626
2627- pub trait IntoItemKind {
2628- fn into_item_kind ( self ) -> ItemKind ;
2629- }
2630-
2631- // FIXME(Centril): These definitions should be unmerged;
2632- // see https://github.com/rust-lang/rust/pull/69194#discussion_r379899975
2633- pub type ForeignItem = Item < AssocItemKind > ;
2634- pub type ForeignItemKind = AssocItemKind ;
2635-
26362627/// Represents associated items.
26372628/// These include items in `impl` and `trait` definitions.
26382629pub type AssocItem = Item < AssocItemKind > ;
26392630
2640- /// Represents non-free item kinds.
2631+ /// Represents associated item kinds.
26412632///
26422633/// The term "provided" in the variants below refers to the item having a default
26432634/// definition / body. Meanwhile, a "required" item lacks a definition / body.
@@ -2646,36 +2637,59 @@ pub type AssocItem = Item<AssocItemKind>;
26462637/// means "provided" and conversely `None` means "required".
26472638#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
26482639pub enum AssocItemKind {
2649- /// A constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
2640+ /// An associated constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
26502641 /// If `def` is parsed, then the constant is provided, and otherwise required.
26512642 Const ( Defaultness , P < Ty > , Option < P < Expr > > ) ,
2652- /// A static item (`static FOO: u8`).
2653- Static ( P < Ty > , Mutability , Option < P < Expr > > ) ,
2654- /// A function.
2643+ /// An associated function.
26552644 Fn ( Defaultness , FnSig , Generics , Option < P < Block > > ) ,
2656- /// A type.
2645+ /// An associated type.
26572646 TyAlias ( Defaultness , Generics , GenericBounds , Option < P < Ty > > ) ,
2658- /// A macro expanding to items.
2647+ /// A macro expanding to associated items.
26592648 Macro ( Mac ) ,
26602649}
26612650
26622651impl AssocItemKind {
26632652 pub fn defaultness ( & self ) -> Defaultness {
26642653 match * self {
26652654 Self :: Const ( def, ..) | Self :: Fn ( def, ..) | Self :: TyAlias ( def, ..) => def,
2666- Self :: Macro ( ..) | Self :: Static ( .. ) => Defaultness :: Final ,
2655+ Self :: Macro ( ..) => Defaultness :: Final ,
26672656 }
26682657 }
26692658}
26702659
2671- impl IntoItemKind for AssocItemKind {
2672- fn into_item_kind ( self ) -> ItemKind {
2673- match self {
2660+ impl From < AssocItemKind > for ItemKind {
2661+ fn from ( assoc_item_kind : AssocItemKind ) -> ItemKind {
2662+ match assoc_item_kind {
26742663 AssocItemKind :: Const ( a, b, c) => ItemKind :: Const ( a, b, c) ,
2675- AssocItemKind :: Static ( a, b, c) => ItemKind :: Static ( a, b, c) ,
26762664 AssocItemKind :: Fn ( a, b, c, d) => ItemKind :: Fn ( a, b, c, d) ,
26772665 AssocItemKind :: TyAlias ( a, b, c, d) => ItemKind :: TyAlias ( a, b, c, d) ,
26782666 AssocItemKind :: Macro ( a) => ItemKind :: Mac ( a) ,
26792667 }
26802668 }
26812669}
2670+
2671+ /// An item in `extern` block.
2672+ #[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
2673+ pub enum ForeignItemKind {
2674+ /// A foreign static item (`static FOO: u8`).
2675+ Static ( P < Ty > , Mutability , Option < P < Expr > > ) ,
2676+ /// A foreign function.
2677+ Fn ( Defaultness , FnSig , Generics , Option < P < Block > > ) ,
2678+ /// A foreign type.
2679+ TyAlias ( Defaultness , Generics , GenericBounds , Option < P < Ty > > ) ,
2680+ /// A macro expanding to foreign items.
2681+ Macro ( Mac ) ,
2682+ }
2683+
2684+ impl From < ForeignItemKind > for ItemKind {
2685+ fn from ( foreign_item_kind : ForeignItemKind ) -> ItemKind {
2686+ match foreign_item_kind {
2687+ ForeignItemKind :: Static ( a, b, c) => ItemKind :: Static ( a, b, c) ,
2688+ ForeignItemKind :: Fn ( a, b, c, d) => ItemKind :: Fn ( a, b, c, d) ,
2689+ ForeignItemKind :: TyAlias ( a, b, c, d) => ItemKind :: TyAlias ( a, b, c, d) ,
2690+ ForeignItemKind :: Macro ( a) => ItemKind :: Mac ( a) ,
2691+ }
2692+ }
2693+ }
2694+
2695+ pub type ForeignItem = Item < ForeignItemKind > ;
0 commit comments