@@ -1780,7 +1780,7 @@ pub struct ImplItem {
17801780 pub span : Span ,
17811781}
17821782
1783- /// Represents different contents within `impl`s .
1783+ /// Represents various kinds of content within an `impl`.
17841784#[ derive( Clone , RustcEncodable , RustcDecodable , Debug , HashStable ) ]
17851785pub enum ImplItemKind {
17861786 /// An associated constant of the given type, set to the constant result
@@ -1794,16 +1794,51 @@ pub enum ImplItemKind {
17941794 Existential ( GenericBounds ) ,
17951795}
17961796
1797- // Bind a type to an associated type (`A = Foo`).
1797+ /// Bind a type to an associated type (i.e., `A = Foo`).
1798+ ///
1799+ /// Bindings like `A: Debug` are represented as a special type `A =
1800+ /// $::Debug` that is understood by the astconv code.
1801+ ///
1802+ /// FIXME(alexreg) -- why have a separate type for the binding case,
1803+ /// wouldn't it be better to make the `ty` field an enum like:
1804+ ///
1805+ /// ```
1806+ /// enum TypeBindingKind {
1807+ /// Equals(...),
1808+ /// Binding(...),
1809+ /// }
1810+ /// ```
17981811#[ derive( Clone , RustcEncodable , RustcDecodable , Debug , HashStable ) ]
17991812pub struct TypeBinding {
18001813 pub hir_id : HirId ,
18011814 #[ stable_hasher( project( name) ) ]
18021815 pub ident : Ident ,
1803- pub ty : P < Ty > ,
1816+ pub kind : TypeBindingKind ,
18041817 pub span : Span ,
18051818}
18061819
1820+ // Represents the two kinds of type bindings.
1821+ #[ derive( Clone , RustcEncodable , RustcDecodable , Debug , HashStable ) ]
1822+ pub enum TypeBindingKind {
1823+ /// E.g., `Foo<Bar: Send>`.
1824+ Constraint {
1825+ bounds : HirVec < GenericBound > ,
1826+ } ,
1827+ /// E.g., `Foo<Bar = ()>`.
1828+ Equality {
1829+ ty : P < Ty > ,
1830+ } ,
1831+ }
1832+
1833+ impl TypeBinding {
1834+ pub fn ty ( & self ) -> & Ty {
1835+ match self . kind {
1836+ TypeBindingKind :: Equality { ref ty } => ty,
1837+ _ => bug ! ( "expected equality type binding for parenthesized generic args" ) ,
1838+ }
1839+ }
1840+ }
1841+
18071842#[ derive( Clone , RustcEncodable , RustcDecodable ) ]
18081843pub struct Ty {
18091844 pub hir_id : HirId ,
@@ -1898,8 +1933,6 @@ pub enum TyKind {
18981933 /// Placeholder for C-variadic arguments. We "spoof" the `VaList` created
18991934 /// from the variadic arguments. This type is only valid up to typeck.
19001935 CVarArgs ( Lifetime ) ,
1901- /// The existential type (i.e., `impl Trait`) that constrains an associated type.
1902- AssocTyExistential ( HirVec < GenericBound > ) ,
19031936}
19041937
19051938#[ derive( Clone , RustcEncodable , RustcDecodable , Debug , HashStable ) ]
@@ -2236,18 +2269,18 @@ impl StructField {
22362269 }
22372270}
22382271
2239- /// Fields and constructor ids of enum variants and structs
2272+ /// Fields and constructor IDs of enum variants and structs.
22402273#[ derive( Clone , RustcEncodable , RustcDecodable , Debug , HashStable ) ]
22412274pub enum VariantData {
2242- /// Struct variant.
2275+ /// A struct variant.
22432276 ///
2244- /// e .g., `Bar { .. }` as in `enum Foo { Bar { .. } }`.
2277+ /// E .g., `Bar { .. }` as in `enum Foo { Bar { .. } }`.
22452278 Struct ( HirVec < StructField > , /* recovered */ bool ) ,
2246- /// Tuple variant.
2279+ /// A tuple variant.
22472280 ///
22482281 /// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`.
22492282 Tuple ( HirVec < StructField > , HirId ) ,
2250- /// Unit variant.
2283+ /// A unit variant.
22512284 ///
22522285 /// E.g., `Bar = ..` as in `enum Foo { Bar = .. }`.
22532286 Unit ( HirId ) ,
0 commit comments