diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-17 04:19:27 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-18 17:54:57 +0530 |
| commit | b08d5eee6a1bb3aaf7385c84b255be964caff9d1 (patch) | |
| tree | 97c9680c5d3bf7547e69a8ff7c7c7a977255ba9d /src/libsyntax | |
| parent | 1debe9d112010a23c76711f557ee6fdc4728f4ec (diff) | |
| download | rust-b08d5eee6a1bb3aaf7385c84b255be964caff9d1.tar.gz rust-b08d5eee6a1bb3aaf7385c84b255be964caff9d1.zip | |
ast: Document Pat and Block
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ec4316150fb..479ae40f0d6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -535,9 +535,13 @@ impl PartialEq for MetaItem_ { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Block { + /// Statements in a block pub stmts: Vec<P<Stmt>>, + /// An expression at the end of the block + /// without a semicolon, if any pub expr: Option<P<Expr>>, pub id: NodeId, + /// Unsafety of the block pub rules: BlockCheckMode, pub span: Span, } @@ -550,8 +554,14 @@ pub struct Pat { } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +/// A single field in a struct pattern +/// +/// For patterns like `Foo {x, y, z}`, `pat` and `ident` point to the same identifier +/// and `is_shorthand` is true. pub struct FieldPat { + /// The identifier for the field pub ident: Ident, + /// The pattern the field is destructured to pub pat: P<Pat>, pub is_shorthand: bool, } @@ -588,15 +598,23 @@ pub enum Pat_ { /// "None" means a * pattern where we don't bind the fields to names. PatEnum(Path, Option<Vec<P<Pat>>>), + /// Destructuring of a struct, e.g. `Foo {x, y, ..}` + /// The `bool` is `true` in the presence of a `..` PatStruct(Path, Vec<Spanned<FieldPat>>, bool), + /// A tuple pattern (`a, b`) PatTup(Vec<P<Pat>>), + /// A `box` pattern PatBox(P<Pat>), - PatRegion(P<Pat>, Mutability), // reference pattern + /// A reference pattern, e.g. `&mut (a, b)` + PatRegion(P<Pat>, Mutability), + /// A literal PatLit(P<Expr>), + /// A range pattern, e.g. `[1...2]` PatRange(P<Expr>, P<Expr>), /// [a, b, ..i, y, z] is represented as: /// PatVec(box [a, b], Some(i), box [y, z]) PatVec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>), + /// A macro pattern; pre-expansion PatMac(Mac), } |
