Skip to content

Commit a5828ff

Browse files
committed
Address huon's comments
1 parent 13881df commit a5828ff

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

src/libsyntax/ast.rs

+21-17
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ pub struct Block {
541541
/// without a semicolon, if any
542542
pub expr: Option<P<Expr>>,
543543
pub id: NodeId,
544-
/// Unsafety of the block
544+
/// Distinguishes between `unsafe { ... }` and `{ ... }`
545545
pub rules: BlockCheckMode,
546546
pub span: Span,
547547
}
@@ -553,11 +553,12 @@ pub struct Pat {
553553
pub span: Span,
554554
}
555555

556-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
557556
/// A single field in a struct pattern
558557
///
559-
/// For patterns like `Foo {x, y, z}`, `pat` and `ident` point to the same identifier
560-
/// and `is_shorthand` is true.
558+
/// Patterns like the fields of Foo `{ x, ref y, ref mut z }`
559+
/// are treated the same as` x: x, y: ref y, z: ref mut z`,
560+
/// except is_shorthand is true
561+
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
561562
pub struct FieldPat {
562563
/// The identifier for the field
563564
pub ident: Ident,
@@ -601,15 +602,15 @@ pub enum Pat_ {
601602
/// Destructuring of a struct, e.g. `Foo {x, y, ..}`
602603
/// The `bool` is `true` in the presence of a `..`
603604
PatStruct(Path, Vec<Spanned<FieldPat>>, bool),
604-
/// A tuple pattern (`a, b`)
605+
/// A tuple pattern `(a, b)`
605606
PatTup(Vec<P<Pat>>),
606607
/// A `box` pattern
607608
PatBox(P<Pat>),
608609
/// A reference pattern, e.g. `&mut (a, b)`
609610
PatRegion(P<Pat>, Mutability),
610611
/// A literal
611612
PatLit(P<Expr>),
612-
/// A range pattern, e.g. `[1...2]`
613+
/// A range pattern, e.g. `1...2`
613614
PatRange(P<Expr>, P<Expr>),
614615
/// [a, b, ..i, y, z] is represented as:
615616
/// PatVec(box [a, b], Some(i), box [y, z])
@@ -817,28 +818,28 @@ pub enum Expr_ {
817818
ExprIfLet(P<Pat>, P<Expr>, P<Block>, Option<P<Expr>>),
818819
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
819820
/// A while loop, with an optional label
820-
/// `'label while expr { block }`
821+
/// `'label: while expr { block }`
821822
ExprWhile(P<Expr>, P<Block>, Option<Ident>),
822823
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
823824
/// A while-let loop, with an optional label
824-
/// `'label while let pat = expr { block }`
825+
/// `'label: while let pat = expr { block }`
825826
/// This is desugared to a combination of `loop` and `match` expressions
826827
ExprWhileLet(P<Pat>, P<Expr>, P<Block>, Option<Ident>),
827828
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
828829
/// A for loop, with an optional label
829-
/// `'label for pat in expr { block }`
830+
/// `'label: for pat in expr { block }`
830831
/// This is desugared to a combination of `loop` and `match` expressions
831832
ExprForLoop(P<Pat>, P<Expr>, P<Block>, Option<Ident>),
832-
/// Conditionless loop (can be exited with break, cont, or ret)
833-
/// `'label loop { block }`
833+
/// Conditionless loop (can be exited with break, continue, or return)
834+
/// `'label: loop { block }`
834835
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
835836
ExprLoop(P<Block>, Option<Ident>),
836837
/// A `match` block, with a source that indicates whether or not it is
837838
/// the result of a desugaring, and if so, which kind
838839
ExprMatch(P<Expr>, Vec<Arm>, MatchSource),
839840
/// A closure (for example, `move |a, b, c| {a + b + c}`)
840841
ExprClosure(CaptureClause, P<FnDecl>, P<Block>),
841-
/// A block
842+
/// A block (`{ ... }`)
842843
ExprBlock(P<Block>),
843844

844845
/// An assignment (`a = foo()`)
@@ -853,7 +854,7 @@ pub enum Expr_ {
853854
ExprTupField(P<Expr>, Spanned<usize>),
854855
/// An indexing operation (`foo[2]`)
855856
ExprIndex(P<Expr>, P<Expr>),
856-
/// A range (`[1..2]`, `[1..]`, or `[..2]`)
857+
/// A range (`1..2`, `1..`, or `..2`)
857858
ExprRange(Option<P<Expr>>, Option<P<Expr>>),
858859

859860
/// Variable reference, possibly containing `::` and/or type
@@ -877,12 +878,14 @@ pub enum Expr_ {
877878
ExprMac(Mac),
878879

879880
/// A struct literal expression.
880-
/// For example, `Foo {x: 1, y: 2}`
881-
ExprStruct(Path, Vec<Field>, Option<P<Expr>> /* base */),
881+
/// For example, `Foo {x: 1, y: 2}`, or
882+
/// `Foo {x: 1, .. base}`, where `base` is the `Option<Expr>`
883+
ExprStruct(Path, Vec<Field>, Option<P<Expr>>),
882884

883885
/// A vector literal constructed from one repeated element.
884-
/// For example, `[u8; 5]`
885-
ExprRepeat(P<Expr> /* element */, P<Expr> /* count */),
886+
/// For example, `[1u8; 5]`. The first expression is the element
887+
/// to be repeated; the second is the number of times to repeat it
888+
ExprRepeat(P<Expr>, P<Expr>),
886889

887890
/// No-op: used solely so we can pretty-print faithfully
888891
ExprParen(P<Expr>)
@@ -1820,6 +1823,7 @@ pub enum ForeignItem_ {
18201823
/// A foreign function
18211824
ForeignItemFn(P<FnDecl>, Generics),
18221825
/// A foreign static item (`static ext: u8`), with optional mutability
1826+
/// (the boolean is true when mutable)
18231827
ForeignItemStatic(P<Ty>, bool),
18241828
}
18251829

0 commit comments

Comments
 (0)