@@ -171,16 +171,19 @@ impl fmt::Debug for Lifetime {
171
171
}
172
172
}
173
173
174
- /// A lifetime definition, eg `'a: 'b+'c+'d`
174
+ /// A lifetime definition, e.g. `'a: 'b+'c+'d`
175
175
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
176
176
pub struct LifetimeDef {
177
177
pub lifetime : Lifetime ,
178
178
pub bounds : Vec < Lifetime >
179
179
}
180
180
181
- /// A "Path" is essentially Rust's notion of a name; for instance:
182
- /// std::cmp::PartialEq . It's represented as a sequence of identifiers,
181
+ /// A "Path" is essentially Rust's notion of a name.
182
+ ///
183
+ /// It's represented as a sequence of identifiers,
183
184
/// along with a bunch of supporting information.
185
+ ///
186
+ /// E.g. `std::cmp::PartialEq`
184
187
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash ) ]
185
188
pub struct Path {
186
189
pub span : Span ,
@@ -220,8 +223,9 @@ impl Path {
220
223
}
221
224
}
222
225
223
- /// A segment of a path: an identifier, an optional lifetime, and a set of
224
- /// types.
226
+ /// A segment of a path: an identifier, an optional lifetime, and a set of types.
227
+ ///
228
+ /// E.g. `std`, `String` or `Box<T>`
225
229
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
226
230
pub struct PathSegment {
227
231
/// The identifier portion of this path segment.
@@ -235,6 +239,9 @@ pub struct PathSegment {
235
239
pub parameters : PathParameters ,
236
240
}
237
241
242
+ /// Parameters of a path segment.
243
+ ///
244
+ /// E.g. `<A, B>` as in `Foo<A, B>` or `(A, B)` as in `Foo(A, B)`
238
245
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
239
246
pub enum PathParameters {
240
247
/// The `<'a, A,B,C>` in `foo::bar::baz::<'a, A,B,C>`
@@ -322,7 +329,8 @@ pub struct AngleBracketedParameterData {
322
329
/// The type parameters for this path segment, if present.
323
330
pub types : P < [ P < Ty > ] > ,
324
331
/// Bindings (equality constraints) on associated types, if present.
325
- /// e.g., `Foo<A=Bar>`.
332
+ ///
333
+ /// E.g., `Foo<A=Bar>`.
326
334
pub bindings : P < [ TypeBinding ] > ,
327
335
}
328
336
@@ -447,7 +455,9 @@ pub enum WherePredicate {
447
455
EqPredicate ( WhereEqPredicate ) ,
448
456
}
449
457
450
- /// A type bound, e.g. `for<'c> Foo: Send+Clone+'c`
458
+ /// A type bound.
459
+ ///
460
+ /// E.g. `for<'c> Foo: Send+Clone+'c`
451
461
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
452
462
pub struct WhereBoundPredicate {
453
463
pub span : Span ,
@@ -459,15 +469,19 @@ pub struct WhereBoundPredicate {
459
469
pub bounds : TyParamBounds ,
460
470
}
461
471
462
- /// A lifetime predicate, e.g. `'a: 'b+'c`
472
+ /// A lifetime predicate.
473
+ ///
474
+ /// E.g. `'a: 'b+'c`
463
475
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
464
476
pub struct WhereRegionPredicate {
465
477
pub span : Span ,
466
478
pub lifetime : Lifetime ,
467
479
pub bounds : Vec < Lifetime > ,
468
480
}
469
481
470
- /// An equality predicate (unsupported), e.g. `T=int`
482
+ /// An equality predicate (unsupported).
483
+ ///
484
+ /// E.g. `T=int`
471
485
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
472
486
pub struct WhereEqPredicate {
473
487
pub id : NodeId ,
@@ -489,12 +503,27 @@ pub struct Crate {
489
503
pub exported_macros : Vec < MacroDef > ,
490
504
}
491
505
506
+ /// A spanned compile-time attribute item.
507
+ ///
508
+ /// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]`
492
509
pub type MetaItem = Spanned < MetaItemKind > ;
493
510
511
+ /// A compile-time attribute item.
512
+ ///
513
+ /// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]`
494
514
#[ derive( Clone , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
495
515
pub enum MetaItemKind {
516
+ /// Word meta item.
517
+ ///
518
+ /// E.g. `test` as in `#[test]`
496
519
Word ( InternedString ) ,
520
+ /// List meta item.
521
+ ///
522
+ /// E.g. `derive(..)` as in `#[derive(..)]`
497
523
List ( InternedString , Vec < P < MetaItem > > ) ,
524
+ /// Name value meta item.
525
+ ///
526
+ /// E.g. `feature = "foo"` as in `#[feature = "foo"]`
498
527
NameValue ( InternedString , Lit ) ,
499
528
}
500
529
@@ -524,6 +553,9 @@ impl PartialEq for MetaItemKind {
524
553
}
525
554
}
526
555
556
+ /// A Block (`{ .. }`).
557
+ ///
558
+ /// E.g. `{ .. }` as in `fn foo() { .. }`
527
559
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
528
560
pub struct Block {
529
561
/// Statements in a block
@@ -876,7 +908,16 @@ impl Decl {
876
908
}
877
909
}
878
910
879
- /// represents one arm of a 'match'
911
+ /// An arm of a 'match'.
912
+ ///
913
+ /// E.g. `0...10 => { println!("match!") }` as in
914
+ ///
915
+ /// ```rust,ignore
916
+ /// match n {
917
+ /// 0...10 => { println!("match!") },
918
+ /// // ..
919
+ /// }
920
+ /// ```
880
921
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
881
922
pub struct Arm {
882
923
pub attrs : Vec < Attribute > ,
@@ -1033,7 +1074,7 @@ pub enum ExprKind {
1033
1074
/// parameters, e.g. foo::bar::<baz>.
1034
1075
///
1035
1076
/// Optionally "qualified",
1036
- /// e .g. `<Vec<T> as SomeTrait>::SomeType`.
1077
+ /// E .g. `<Vec<T> as SomeTrait>::SomeType`.
1037
1078
Path ( Option < QSelf > , Path ) ,
1038
1079
1039
1080
/// A referencing operation (`&a` or `&mut a`)
@@ -1075,7 +1116,7 @@ pub enum ExprKind {
1075
1116
/// separately. `position` represents the index of the associated
1076
1117
/// item qualified with this Self type.
1077
1118
///
1078
- /// ```ignore
1119
+ /// ```rust, ignore
1079
1120
/// <Vec<T> as a::b::Trait>::AssociatedItem
1080
1121
/// ^~~~~ ~~~~~~~~~~~~~~^
1081
1122
/// ty position = 3
@@ -1319,6 +1360,9 @@ pub enum LitIntType {
1319
1360
Unsuffixed ,
1320
1361
}
1321
1362
1363
+ /// Literal kind.
1364
+ ///
1365
+ /// E.g. `"foo"`, `42`, `12.34` or `bool`
1322
1366
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1323
1367
pub enum LitKind {
1324
1368
/// A string literal (`"foo"`)
@@ -1586,8 +1630,8 @@ pub struct BareFnTy {
1586
1630
pub decl : P < FnDecl >
1587
1631
}
1588
1632
1589
- #[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1590
1633
/// The different kinds of types recognized by the compiler
1634
+ #[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1591
1635
pub enum TyKind {
1592
1636
Vec ( P < Ty > ) ,
1593
1637
/// A fixed length array (`[T; n]`)
@@ -1622,12 +1666,18 @@ pub enum TyKind {
1622
1666
Mac ( Mac ) ,
1623
1667
}
1624
1668
1669
+ /// Inline assembly dialect.
1670
+ ///
1671
+ /// E.g. `"intel"` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")``
1625
1672
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug , Copy ) ]
1626
1673
pub enum AsmDialect {
1627
1674
Att ,
1628
1675
Intel ,
1629
1676
}
1630
1677
1678
+ /// Inline assembly.
1679
+ ///
1680
+ /// E.g. `"={eax}"(result)` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")``
1631
1681
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1632
1682
pub struct InlineAsmOutput {
1633
1683
pub constraint : InternedString ,
@@ -1636,6 +1686,9 @@ pub struct InlineAsmOutput {
1636
1686
pub is_indirect : bool ,
1637
1687
}
1638
1688
1689
+ /// Inline assembly.
1690
+ ///
1691
+ /// E.g. `asm!("NOP");`
1639
1692
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1640
1693
pub struct InlineAsm {
1641
1694
pub asm : InternedString ,
@@ -1649,7 +1702,9 @@ pub struct InlineAsm {
1649
1702
pub expn_id : ExpnId ,
1650
1703
}
1651
1704
1652
- /// represents an argument in a function header
1705
+ /// An argument in a function header.
1706
+ ///
1707
+ /// E.g. `bar: usize` as in `fn foo(bar: usize)`
1653
1708
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1654
1709
pub struct Arg {
1655
1710
pub ty : P < Ty > ,
@@ -1658,6 +1713,8 @@ pub struct Arg {
1658
1713
}
1659
1714
1660
1715
/// Alternative representation for `Arg`s describing `self` parameter of methods.
1716
+ ///
1717
+ /// E.g. `&mut self` as in `fn foo(&mut self)`
1661
1718
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1662
1719
pub enum SelfKind {
1663
1720
/// `self`, `mut self`
@@ -1724,7 +1781,9 @@ impl Arg {
1724
1781
}
1725
1782
}
1726
1783
1727
- /// Represents the header (not the body) of a function declaration
1784
+ /// Header (not the body) of a function declaration.
1785
+ ///
1786
+ /// E.g. `fn foo(bar: baz)`
1728
1787
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1729
1788
pub struct FnDecl {
1730
1789
pub inputs : Vec < Arg > ,
@@ -1811,6 +1870,9 @@ impl FunctionRetTy {
1811
1870
}
1812
1871
}
1813
1872
1873
+ /// Module declaration.
1874
+ ///
1875
+ /// E.g. `mod foo;` or `mod foo { .. }`
1814
1876
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1815
1877
pub struct Mod {
1816
1878
/// A span from the first token past `{` to the last token until `}`.
@@ -1820,6 +1882,9 @@ pub struct Mod {
1820
1882
pub items : Vec < P < Item > > ,
1821
1883
}
1822
1884
1885
+ /// Foreign module declaration.
1886
+ ///
1887
+ /// E.g. `extern { .. }` or `extern C { .. }`
1823
1888
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1824
1889
pub struct ForeignMod {
1825
1890
pub abi : Abi ,
@@ -1836,7 +1901,7 @@ pub struct Variant_ {
1836
1901
pub name : Ident ,
1837
1902
pub attrs : Vec < Attribute > ,
1838
1903
pub data : VariantData ,
1839
- /// Explicit discriminant, eg `Foo = 1`
1904
+ /// Explicit discriminant, e.g. `Foo = 1`
1840
1905
pub disr_expr : Option < P < Expr > > ,
1841
1906
}
1842
1907
@@ -1846,12 +1911,12 @@ pub type Variant = Spanned<Variant_>;
1846
1911
pub enum PathListItemKind {
1847
1912
Ident {
1848
1913
name : Ident ,
1849
- /// renamed in list, eg `use foo::{bar as baz};`
1914
+ /// renamed in list, e.g. `use foo::{bar as baz};`
1850
1915
rename : Option < Ident > ,
1851
1916
id : NodeId
1852
1917
} ,
1853
1918
Mod {
1854
- /// renamed in list, eg `use foo::{self as baz};`
1919
+ /// renamed in list, e.g. `use foo::{self as baz};`
1855
1920
rename : Option < Ident > ,
1856
1921
id : NodeId
1857
1922
}
@@ -1964,6 +2029,9 @@ pub enum Visibility {
1964
2029
Inherited ,
1965
2030
}
1966
2031
2032
+ /// Field of a struct.
2033
+ ///
2034
+ /// E.g. `bar: usize` as in `struct Foo { bar: usize }`
1967
2035
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1968
2036
pub struct StructField {
1969
2037
pub span : Span ,
@@ -1987,8 +2055,17 @@ pub struct StructField {
1987
2055
/// Id of the whole struct lives in `Item`.
1988
2056
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1989
2057
pub enum VariantData {
2058
+ /// Struct variant.
2059
+ ///
2060
+ /// E.g. `Bar { .. }` as in `enum Foo { Bar { .. } }`
1990
2061
Struct ( Vec < StructField > , NodeId ) ,
2062
+ /// Tuple variant.
2063
+ ///
2064
+ /// E.g. `Bar(..)` as in `enum Foo { Bar(..) }`
1991
2065
Tuple ( Vec < StructField > , NodeId ) ,
2066
+ /// Unit variant.
2067
+ ///
2068
+ /// E.g. `Bar = ..` as in `enum Foo { Bar = .. }`
1992
2069
Unit ( NodeId ) ,
1993
2070
}
1994
2071
@@ -2040,44 +2117,66 @@ impl Item {
2040
2117
2041
2118
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
2042
2119
pub enum ItemKind {
2043
- /// An`extern crate` item, with optional original crate name,
2120
+ /// An`extern crate` item, with optional original crate name.
2044
2121
///
2045
- /// e .g. `extern crate foo` or `extern crate foo_bar as foo`
2122
+ /// E .g. `extern crate foo` or `extern crate foo_bar as foo`
2046
2123
ExternCrate ( Option < Name > ) ,
2047
- /// A `use` or `pub use` item
2124
+ /// A use declaration (`use` or `pub use`) item.
2125
+ ///
2126
+ /// E.g. `use foo;`, `use foo::bar;` or `use foo::bar as FooBar;`
2048
2127
Use ( P < ViewPath > ) ,
2049
-
2050
- /// A `static` item
2128
+ /// A static item (`static` or `pub static`).
2129
+ ///
2130
+ /// E.g. `static FOO: i32 = 42;` or `static FOO: &'static str = "bar";`
2051
2131
Static ( P < Ty > , Mutability , P < Expr > ) ,
2052
- /// A `const` item
2132
+ /// A constant item (`const` or `pub const`).
2133
+ ///
2134
+ /// E.g. `const FOO: i32 = 42;`
2053
2135
Const ( P < Ty > , P < Expr > ) ,
2054
- /// A function declaration
2136
+ /// A function declaration (`fn` or `pub fn`).
2137
+ ///
2138
+ /// E.g. `fn foo(bar: usize) -> usize { .. }`
2055
2139
Fn ( P < FnDecl > , Unsafety , Constness , Abi , Generics , P < Block > ) ,
2056
- /// A module
2140
+ /// A module declaration (`mod` or `pub mod`).
2141
+ ///
2142
+ /// E.g. `mod foo;` or `mod foo { .. }`
2057
2143
Mod ( Mod ) ,
2058
- /// An external module
2144
+ /// An external module (`extern` or `pub extern`).
2145
+ ///
2146
+ /// E.g. `extern {}` or `extern "C" {}`
2059
2147
ForeignMod ( ForeignMod ) ,
2060
- /// A type alias, e.g. `type Foo = Bar<u8>`
2148
+ /// A type alias (`type` or `pub type`).
2149
+ ///
2150
+ /// E.g. `type Foo = Bar<u8>;`
2061
2151
Ty ( P < Ty > , Generics ) ,
2062
- /// An enum definition, e.g. `enum Foo<A, B> {C<A>, D<B>}`
2152
+ /// An enum definition (`enum` or `pub enum`).
2153
+ ///
2154
+ /// E.g. `enum Foo<A, B> { C<A>, D<B> }`
2063
2155
Enum ( EnumDef , Generics ) ,
2064
- /// A struct definition, e.g. `struct Foo<A> {x: A}`
2156
+ /// A struct definition (`struct` or `pub struct`).
2157
+ ///
2158
+ /// E.g. `struct Foo<A> { x: A }`
2065
2159
Struct ( VariantData , Generics ) ,
2066
- /// Represents a Trait Declaration
2160
+ /// A Trait declaration (`trait` or `pub trait`).
2161
+ ///
2162
+ /// E.g. `trait Foo { .. }` or `trait Foo<T> { .. }`
2067
2163
Trait ( Unsafety , Generics , TyParamBounds , Vec < TraitItem > ) ,
2068
-
2069
- // Default trait implementations
2164
+ // Default trait implementation.
2070
2165
///
2071
- // `impl Trait for .. {}`
2166
+ /// E.g. `impl Trait for .. {}` or `impl<T> Trait<T> for .. {}`
2072
2167
DefaultImpl ( Unsafety , TraitRef ) ,
2073
- /// An implementation, eg `impl<A> Trait for Foo { .. }`
2168
+ /// An implementation.
2169
+ ///
2170
+ /// E.g. `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`
2074
2171
Impl ( Unsafety ,
2075
2172
ImplPolarity ,
2076
2173
Generics ,
2077
2174
Option < TraitRef > , // (optional) trait this impl implements
2078
2175
P < Ty > , // self
2079
2176
Vec < ImplItem > ) ,
2080
- /// A macro invocation (which includes macro definition)
2177
+ /// A macro invocation (which includes macro definition).
2178
+ ///
2179
+ /// E.g. `macro_rules! foo { .. }` or `foo!(..)`
2081
2180
Mac ( Mac ) ,
2082
2181
}
2083
2182
0 commit comments