From a5828ff7b0203ac378974c2d30ed94a14073895a Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 18 Mar 2015 18:06:10 +0530 Subject: Address huon's comments --- src/libsyntax/ast.rs | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 26e10a35150..5c275715352 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -541,7 +541,7 @@ pub struct Block { /// without a semicolon, if any pub expr: Option>, pub id: NodeId, - /// Unsafety of the block + /// Distinguishes between `unsafe { ... }` and `{ ... }` pub rules: BlockCheckMode, pub span: Span, } @@ -553,11 +553,12 @@ pub struct Pat { pub span: Span, } -#[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. +/// Patterns like the fields of Foo `{ x, ref y, ref mut z }` +/// are treated the same as` x: x, y: ref y, z: ref mut z`, +/// except is_shorthand is true +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct FieldPat { /// The identifier for the field pub ident: Ident, @@ -601,7 +602,7 @@ pub enum Pat_ { /// Destructuring of a struct, e.g. `Foo {x, y, ..}` /// The `bool` is `true` in the presence of a `..` PatStruct(Path, Vec>, bool), - /// A tuple pattern (`a, b`) + /// A tuple pattern `(a, b)` PatTup(Vec>), /// A `box` pattern PatBox(P), @@ -609,7 +610,7 @@ pub enum Pat_ { PatRegion(P, Mutability), /// A literal PatLit(P), - /// A range pattern, e.g. `[1...2]` + /// A range pattern, e.g. `1...2` PatRange(P, P), /// [a, b, ..i, y, z] is represented as: /// PatVec(box [a, b], Some(i), box [y, z]) @@ -817,20 +818,20 @@ pub enum Expr_ { ExprIfLet(P, P, P, Option>), // FIXME #6993: change to Option ... or not, if these are hygienic. /// A while loop, with an optional label - /// `'label while expr { block }` + /// `'label: while expr { block }` ExprWhile(P, P, Option), // FIXME #6993: change to Option ... or not, if these are hygienic. /// A while-let loop, with an optional label - /// `'label while let pat = expr { block }` + /// `'label: while let pat = expr { block }` /// This is desugared to a combination of `loop` and `match` expressions ExprWhileLet(P, P, P, Option), // FIXME #6993: change to Option ... or not, if these are hygienic. /// A for loop, with an optional label - /// `'label for pat in expr { block }` + /// `'label: for pat in expr { block }` /// This is desugared to a combination of `loop` and `match` expressions ExprForLoop(P, P, P, Option), - /// Conditionless loop (can be exited with break, cont, or ret) - /// `'label loop { block }` + /// Conditionless loop (can be exited with break, continue, or return) + /// `'label: loop { block }` // FIXME #6993: change to Option ... or not, if these are hygienic. ExprLoop(P, Option), /// A `match` block, with a source that indicates whether or not it is @@ -838,7 +839,7 @@ pub enum Expr_ { ExprMatch(P, Vec, MatchSource), /// A closure (for example, `move |a, b, c| {a + b + c}`) ExprClosure(CaptureClause, P, P), - /// A block + /// A block (`{ ... }`) ExprBlock(P), /// An assignment (`a = foo()`) @@ -853,7 +854,7 @@ pub enum Expr_ { ExprTupField(P, Spanned), /// An indexing operation (`foo[2]`) ExprIndex(P, P), - /// A range (`[1..2]`, `[1..]`, or `[..2]`) + /// A range (`1..2`, `1..`, or `..2`) ExprRange(Option>, Option>), /// Variable reference, possibly containing `::` and/or type @@ -877,12 +878,14 @@ pub enum Expr_ { ExprMac(Mac), /// A struct literal expression. - /// For example, `Foo {x: 1, y: 2}` - ExprStruct(Path, Vec, Option> /* base */), + /// For example, `Foo {x: 1, y: 2}`, or + /// `Foo {x: 1, .. base}`, where `base` is the `Option` + ExprStruct(Path, Vec, Option>), /// A vector literal constructed from one repeated element. - /// For example, `[u8; 5]` - ExprRepeat(P /* element */, P /* count */), + /// For example, `[1u8; 5]`. The first expression is the element + /// to be repeated; the second is the number of times to repeat it + ExprRepeat(P, P), /// No-op: used solely so we can pretty-print faithfully ExprParen(P) @@ -1820,6 +1823,7 @@ pub enum ForeignItem_ { /// A foreign function ForeignItemFn(P, Generics), /// A foreign static item (`static ext: u8`), with optional mutability + /// (the boolean is true when mutable) ForeignItemStatic(P, bool), } -- cgit 1.4.1-3-g733a5