Skip to content

Commit 1debe9d

Browse files
committed
ast: Document paths and where clauses
1 parent c42067c commit 1debe9d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/libsyntax/ast.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl PartialEq for Ident {
150150

151151
/// A SyntaxContext represents a chain of macro-expandings
152152
/// and renamings. Each macro expansion corresponds to
153-
/// a fresh usize
153+
/// a fresh u32
154154
155155
// I'm representing this syntax context as an index into
156156
// a table, in order to work around a compiler bug
@@ -216,6 +216,7 @@ pub struct Lifetime {
216216
}
217217

218218
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
219+
/// A lifetime definition, eg `'a: 'b+'c+'d`
219220
pub struct LifetimeDef {
220221
pub lifetime: Lifetime,
221222
pub bounds: Vec<Lifetime>
@@ -251,7 +252,9 @@ pub struct PathSegment {
251252

252253
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
253254
pub enum PathParameters {
255+
/// The `<'a, A,B,C>` in `foo::bar::baz::<'a, A,B,C>`
254256
AngleBracketedParameters(AngleBracketedParameterData),
257+
/// The `(A,B)` and `C` in `Foo(A,B) -> C`
255258
ParenthesizedParameters(ParenthesizedParameterData),
256259
}
257260

@@ -436,34 +439,45 @@ impl Generics {
436439
}
437440
}
438441

442+
/// A `where` clause in a definition
439443
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
440444
pub struct WhereClause {
441445
pub id: NodeId,
442446
pub predicates: Vec<WherePredicate>,
443447
}
444448

449+
/// A single predicate in a `where` clause
445450
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
446451
pub enum WherePredicate {
452+
/// A type binding, eg `for<'c> Foo: Send+Clone+'c`
447453
BoundPredicate(WhereBoundPredicate),
454+
/// A lifetime predicate, e.g. `'a: 'b+'c`
448455
RegionPredicate(WhereRegionPredicate),
456+
/// An equality predicate (unsupported)
449457
EqPredicate(WhereEqPredicate)
450458
}
451459

460+
/// A type bound, eg `for<'c> Foo: Send+Clone+'c`
452461
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
453462
pub struct WhereBoundPredicate {
454463
pub span: Span,
464+
/// Any lifetimes from a `for` binding
455465
pub bound_lifetimes: Vec<LifetimeDef>,
466+
/// The type being bounded
456467
pub bounded_ty: P<Ty>,
468+
/// Trait and lifetime bounds (`Clone+Send+'static`)
457469
pub bounds: OwnedSlice<TyParamBound>,
458470
}
459471

472+
/// A lifetime predicate, e.g. `'a: 'b+'c`
460473
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
461474
pub struct WhereRegionPredicate {
462475
pub span: Span,
463476
pub lifetime: Lifetime,
464477
pub bounds: Vec<Lifetime>,
465478
}
466479

480+
/// An equality predicate (unsupported), e.g. `T=int`
467481
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
468482
pub struct WhereEqPredicate {
469483
pub id: NodeId,

0 commit comments

Comments
 (0)