From bb832c2560c8d2c6d1a47d9a9bb0eed518f0b3ad Mon Sep 17 00:00:00 2001 From: Andre Bogus Date: Mon, 18 Mar 2019 09:02:57 +0100 Subject: [PATCH 1/2] some small HIR doc improvements --- src/librustc/hir/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 88ab58d10fc34..8941158e561d1 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -816,6 +816,9 @@ pub struct MacroDef { pub legacy: bool, } +/// A block of statements `{ .. }`, which may have a label (in this case the +/// `targeted_by_break` field will be `true`) and may be `unsafe` by means of +/// the `rules` being anything but `DefaultBlock`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Block { /// Statements in a block. @@ -1178,6 +1181,7 @@ impl fmt::Debug for Stmt { } } +/// The contents of a statement. #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum StmtKind { /// A local (`let`) binding. @@ -1208,21 +1212,28 @@ impl StmtKind { #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Local { pub pat: P, + /// Type annotation, if any (otherwise the type will be inferred). pub ty: Option>, /// Initializer expression to set the value, if any. pub init: Option>, pub hir_id: HirId, pub span: Span, pub attrs: ThinVec, + /// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop + /// desugaring. Otherwise will be `Normal`. pub source: LocalSource, } -/// Represents a single arm of a `match` expression. +/// Represents a single arm of a `match` expression, e.g. +/// ` (if ) => `. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Arm { pub attrs: HirVec, + /// Multiple patterns can be combined with `|` pub pats: HirVec>, + /// Optional guard clause. pub guard: Option, + /// The action to take if this arm matches. pub body: P, } From 37789c4a1d6e46af2ef619f5640c05764b875dbb Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 19 Mar 2019 06:10:59 +0100 Subject: [PATCH 2/2] Update src/librustc/hir/mod.rs Co-Authored-By: llogiq --- src/librustc/hir/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 8941158e561d1..24c145b3811e3 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1233,7 +1233,7 @@ pub struct Arm { pub pats: HirVec>, /// Optional guard clause. pub guard: Option, - /// The action to take if this arm matches. + /// The expression the arm evaluates to if this arm matches. pub body: P, }