@@ -171,16 +171,19 @@ impl fmt::Debug for Lifetime {
171171 }
172172}
173173
174- /// A lifetime definition, eg `'a: 'b+'c+'d`
174+ /// A lifetime definition, e.g. `'a: 'b+'c+'d`
175175#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
176176pub struct LifetimeDef {
177177 pub lifetime : Lifetime ,
178178 pub bounds : Vec < Lifetime >
179179}
180180
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,
183184/// along with a bunch of supporting information.
185+ ///
186+ /// E.g. `std::cmp::PartialEq`
184187#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash ) ]
185188pub struct Path {
186189 pub span : Span ,
@@ -220,8 +223,9 @@ impl Path {
220223 }
221224}
222225
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>`
225229#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
226230pub struct PathSegment {
227231 /// The identifier portion of this path segment.
@@ -235,6 +239,9 @@ pub struct PathSegment {
235239 pub parameters : PathParameters ,
236240}
237241
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)`
238245#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
239246pub enum PathParameters {
240247 /// The `<'a, A,B,C>` in `foo::bar::baz::<'a, A,B,C>`
@@ -322,7 +329,8 @@ pub struct AngleBracketedParameterData {
322329 /// The type parameters for this path segment, if present.
323330 pub types : P < [ P < Ty > ] > ,
324331 /// Bindings (equality constraints) on associated types, if present.
325- /// e.g., `Foo<A=Bar>`.
332+ ///
333+ /// E.g., `Foo<A=Bar>`.
326334 pub bindings : P < [ TypeBinding ] > ,
327335}
328336
@@ -447,7 +455,9 @@ pub enum WherePredicate {
447455 EqPredicate ( WhereEqPredicate ) ,
448456}
449457
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`
451461#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
452462pub struct WhereBoundPredicate {
453463 pub span : Span ,
@@ -459,15 +469,19 @@ pub struct WhereBoundPredicate {
459469 pub bounds : TyParamBounds ,
460470}
461471
462- /// A lifetime predicate, e.g. `'a: 'b+'c`
472+ /// A lifetime predicate.
473+ ///
474+ /// E.g. `'a: 'b+'c`
463475#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
464476pub struct WhereRegionPredicate {
465477 pub span : Span ,
466478 pub lifetime : Lifetime ,
467479 pub bounds : Vec < Lifetime > ,
468480}
469481
470- /// An equality predicate (unsupported), e.g. `T=int`
482+ /// An equality predicate (unsupported).
483+ ///
484+ /// E.g. `T=int`
471485#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
472486pub struct WhereEqPredicate {
473487 pub id : NodeId ,
@@ -489,12 +503,27 @@ pub struct Crate {
489503 pub exported_macros : Vec < MacroDef > ,
490504}
491505
506+ /// A spanned compile-time attribute item.
507+ ///
508+ /// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]`
492509pub type MetaItem = Spanned < MetaItemKind > ;
493510
511+ /// A compile-time attribute item.
512+ ///
513+ /// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]`
494514#[ derive( Clone , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
495515pub enum MetaItemKind {
516+ /// Word meta item.
517+ ///
518+ /// E.g. `test` as in `#[test]`
496519 Word ( InternedString ) ,
520+ /// List meta item.
521+ ///
522+ /// E.g. `derive(..)` as in `#[derive(..)]`
497523 List ( InternedString , Vec < P < MetaItem > > ) ,
524+ /// Name value meta item.
525+ ///
526+ /// E.g. `feature = "foo"` as in `#[feature = "foo"]`
498527 NameValue ( InternedString , Lit ) ,
499528}
500529
@@ -524,6 +553,9 @@ impl PartialEq for MetaItemKind {
524553 }
525554}
526555
556+ /// A Block (`{ .. }`).
557+ ///
558+ /// E.g. `{ .. }` as in `fn foo() { .. }`
527559#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
528560pub struct Block {
529561 /// Statements in a block
@@ -876,7 +908,16 @@ impl Decl {
876908 }
877909}
878910
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+ /// ```
880921#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
881922pub struct Arm {
882923 pub attrs : Vec < Attribute > ,
@@ -1033,7 +1074,7 @@ pub enum ExprKind {
10331074 /// parameters, e.g. foo::bar::<baz>.
10341075 ///
10351076 /// Optionally "qualified",
1036- /// e .g. `<Vec<T> as SomeTrait>::SomeType`.
1077+ /// E .g. `<Vec<T> as SomeTrait>::SomeType`.
10371078 Path ( Option < QSelf > , Path ) ,
10381079
10391080 /// A referencing operation (`&a` or `&mut a`)
@@ -1075,7 +1116,7 @@ pub enum ExprKind {
10751116/// separately. `position` represents the index of the associated
10761117/// item qualified with this Self type.
10771118///
1078- /// ```ignore
1119+ /// ```rust, ignore
10791120/// <Vec<T> as a::b::Trait>::AssociatedItem
10801121/// ^~~~~ ~~~~~~~~~~~~~~^
10811122/// ty position = 3
@@ -1319,6 +1360,9 @@ pub enum LitIntType {
13191360 Unsuffixed ,
13201361}
13211362
1363+ /// Literal kind.
1364+ ///
1365+ /// E.g. `"foo"`, `42`, `12.34` or `bool`
13221366#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
13231367pub enum LitKind {
13241368 /// A string literal (`"foo"`)
@@ -1586,8 +1630,8 @@ pub struct BareFnTy {
15861630 pub decl : P < FnDecl >
15871631}
15881632
1589- #[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
15901633/// The different kinds of types recognized by the compiler
1634+ #[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
15911635pub enum TyKind {
15921636 Vec ( P < Ty > ) ,
15931637 /// A fixed length array (`[T; n]`)
@@ -1622,12 +1666,18 @@ pub enum TyKind {
16221666 Mac ( Mac ) ,
16231667}
16241668
1669+ /// Inline assembly dialect.
1670+ ///
1671+ /// E.g. `"intel"` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")``
16251672#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug , Copy ) ]
16261673pub enum AsmDialect {
16271674 Att ,
16281675 Intel ,
16291676}
16301677
1678+ /// Inline assembly.
1679+ ///
1680+ /// E.g. `"={eax}"(result)` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")``
16311681#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
16321682pub struct InlineAsmOutput {
16331683 pub constraint : InternedString ,
@@ -1636,6 +1686,9 @@ pub struct InlineAsmOutput {
16361686 pub is_indirect : bool ,
16371687}
16381688
1689+ /// Inline assembly.
1690+ ///
1691+ /// E.g. `asm!("NOP");`
16391692#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
16401693pub struct InlineAsm {
16411694 pub asm : InternedString ,
@@ -1649,7 +1702,9 @@ pub struct InlineAsm {
16491702 pub expn_id : ExpnId ,
16501703}
16511704
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)`
16531708#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
16541709pub struct Arg {
16551710 pub ty : P < Ty > ,
@@ -1658,6 +1713,8 @@ pub struct Arg {
16581713}
16591714
16601715/// Alternative representation for `Arg`s describing `self` parameter of methods.
1716+ ///
1717+ /// E.g. `&mut self` as in `fn foo(&mut self)`
16611718#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
16621719pub enum SelfKind {
16631720 /// `self`, `mut self`
@@ -1724,7 +1781,9 @@ impl Arg {
17241781 }
17251782}
17261783
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)`
17281787#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
17291788pub struct FnDecl {
17301789 pub inputs : Vec < Arg > ,
@@ -1811,6 +1870,9 @@ impl FunctionRetTy {
18111870 }
18121871}
18131872
1873+ /// Module declaration.
1874+ ///
1875+ /// E.g. `mod foo;` or `mod foo { .. }`
18141876#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
18151877pub struct Mod {
18161878 /// A span from the first token past `{` to the last token until `}`.
@@ -1820,6 +1882,9 @@ pub struct Mod {
18201882 pub items : Vec < P < Item > > ,
18211883}
18221884
1885+ /// Foreign module declaration.
1886+ ///
1887+ /// E.g. `extern { .. }` or `extern C { .. }`
18231888#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
18241889pub struct ForeignMod {
18251890 pub abi : Abi ,
@@ -1836,7 +1901,7 @@ pub struct Variant_ {
18361901 pub name : Ident ,
18371902 pub attrs : Vec < Attribute > ,
18381903 pub data : VariantData ,
1839- /// Explicit discriminant, eg `Foo = 1`
1904+ /// Explicit discriminant, e.g. `Foo = 1`
18401905 pub disr_expr : Option < P < Expr > > ,
18411906}
18421907
@@ -1846,12 +1911,12 @@ pub type Variant = Spanned<Variant_>;
18461911pub enum PathListItemKind {
18471912 Ident {
18481913 name : Ident ,
1849- /// renamed in list, eg `use foo::{bar as baz};`
1914+ /// renamed in list, e.g. `use foo::{bar as baz};`
18501915 rename : Option < Ident > ,
18511916 id : NodeId
18521917 } ,
18531918 Mod {
1854- /// renamed in list, eg `use foo::{self as baz};`
1919+ /// renamed in list, e.g. `use foo::{self as baz};`
18551920 rename : Option < Ident > ,
18561921 id : NodeId
18571922 }
@@ -1964,6 +2029,9 @@ pub enum Visibility {
19642029 Inherited ,
19652030}
19662031
2032+ /// Field of a struct.
2033+ ///
2034+ /// E.g. `bar: usize` as in `struct Foo { bar: usize }`
19672035#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
19682036pub struct StructField {
19692037 pub span : Span ,
@@ -1987,8 +2055,17 @@ pub struct StructField {
19872055/// Id of the whole struct lives in `Item`.
19882056#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
19892057pub enum VariantData {
2058+ /// Struct variant.
2059+ ///
2060+ /// E.g. `Bar { .. }` as in `enum Foo { Bar { .. } }`
19902061 Struct ( Vec < StructField > , NodeId ) ,
2062+ /// Tuple variant.
2063+ ///
2064+ /// E.g. `Bar(..)` as in `enum Foo { Bar(..) }`
19912065 Tuple ( Vec < StructField > , NodeId ) ,
2066+ /// Unit variant.
2067+ ///
2068+ /// E.g. `Bar = ..` as in `enum Foo { Bar = .. }`
19922069 Unit ( NodeId ) ,
19932070}
19942071
@@ -2040,44 +2117,66 @@ impl Item {
20402117
20412118#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
20422119pub enum ItemKind {
2043- /// An`extern crate` item, with optional original crate name,
2120+ /// An`extern crate` item, with optional original crate name.
20442121 ///
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`
20462123 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;`
20482127 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";`
20512131 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;`
20532135 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 { .. }`
20552139 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 { .. }`
20572143 Mod ( Mod ) ,
2058- /// An external module
2144+ /// An external module (`extern` or `pub extern`).
2145+ ///
2146+ /// E.g. `extern {}` or `extern "C" {}`
20592147 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>;`
20612151 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> }`
20632155 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 }`
20652159 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> { .. }`
20672163 Trait ( Unsafety , Generics , TyParamBounds , Vec < TraitItem > ) ,
2068-
2069- // Default trait implementations
2164+ // Default trait implementation.
20702165 ///
2071- // `impl Trait for .. {}`
2166+ /// E.g. `impl Trait for .. {}` or `impl<T> Trait<T> for .. {}`
20722167 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> { .. }`
20742171 Impl ( Unsafety ,
20752172 ImplPolarity ,
20762173 Generics ,
20772174 Option < TraitRef > , // (optional) trait this impl implements
20782175 P < Ty > , // self
20792176 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!(..)`
20812180 Mac ( Mac ) ,
20822181}
20832182
0 commit comments