@@ -1603,23 +1603,16 @@ pub struct FnSig {
1603
1603
pub decl : P < FnDecl > ,
1604
1604
}
1605
1605
1606
- pub type TraitItem = ImplItem < TraitItemKind > ;
1606
+ // FIXME(Centril): Remove all of these.
1607
+ pub type TraitItem = AssocItem < AssocItemKind > ;
1608
+ pub type TraitItemKind = AssocItemKind ;
1609
+ pub type ImplItem = AssocItem < AssocItemKind > ;
1610
+ pub type ImplItemKind = AssocItemKind ;
1607
1611
1608
- /// Represents the kind of an item declaration within a trait declaration,
1609
- /// possibly including a default implementation. A trait item is
1610
- /// either required (meaning it doesn't have an implementation, just a
1611
- /// signature) or provided (meaning it has a default implementation).
1612
+ /// Represents associated items.
1613
+ /// These include items in `impl` and `trait` definitions.
1612
1614
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
1613
- pub enum TraitItemKind {
1614
- Const ( P < Ty > , Option < P < Expr > > ) ,
1615
- Method ( FnSig , Option < P < Block > > ) ,
1616
- TyAlias ( GenericBounds , Option < P < Ty > > ) ,
1617
- Macro ( Mac ) ,
1618
- }
1619
-
1620
- /// Represents anything within an `impl` block.
1621
- #[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
1622
- pub struct ImplItem < K = ImplItemKind > {
1615
+ pub struct AssocItem < K = ImplItemKind > {
1623
1616
pub attrs : Vec < Attribute > ,
1624
1617
pub id : NodeId ,
1625
1618
pub span : Span ,
@@ -1634,11 +1627,25 @@ pub struct ImplItem<K = ImplItemKind> {
1634
1627
}
1635
1628
1636
1629
/// Represents various kinds of content within an `impl`.
1637
- #[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
1638
- pub enum ImplItemKind {
1630
+ ///
1631
+ /// The term "provided" in the variants below refers to the item having a default
1632
+ /// definition / body. Meanwhile, a "required" item lacks a definition / body.
1633
+ /// In an implementation, all items must be provided.
1634
+ /// The `Option`s below denote the bodies, where `Some(_)`
1635
+ /// means "provided" and conversely `None` means "required".
1636
+ #[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
1637
+ pub enum AssocItemKind {
1638
+ /// An associated constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
1639
+ /// If `def` is parsed, then the associated constant is provided, and otherwise required.
1639
1640
Const ( P < Ty > , Option < P < Expr > > ) ,
1641
+
1642
+ /// An associated function.
1640
1643
Method ( FnSig , Option < P < Block > > ) ,
1644
+
1645
+ /// An associated type.
1641
1646
TyAlias ( GenericBounds , Option < P < Ty > > ) ,
1647
+
1648
+ /// A macro expanding to an associated item.
1642
1649
Macro ( Mac ) ,
1643
1650
}
1644
1651
0 commit comments