Skip to content

Commit bd6a70d

Browse files
Rollup merge of rust-lang#59273 - llogiq:hir-docs, r=matthewjasper
some small HIR doc improvements
2 parents 4103238 + 37789c4 commit bd6a70d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/librustc/hir/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,9 @@ pub struct MacroDef {
815815
pub legacy: bool,
816816
}
817817

818+
/// A block of statements `{ .. }`, which may have a label (in this case the
819+
/// `targeted_by_break` field will be `true`) and may be `unsafe` by means of
820+
/// the `rules` being anything but `DefaultBlock`.
818821
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
819822
pub struct Block {
820823
/// Statements in a block.
@@ -1177,6 +1180,7 @@ impl fmt::Debug for Stmt {
11771180
}
11781181
}
11791182

1183+
/// The contents of a statement.
11801184
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
11811185
pub enum StmtKind {
11821186
/// A local (`let`) binding.
@@ -1207,21 +1211,28 @@ impl StmtKind {
12071211
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
12081212
pub struct Local {
12091213
pub pat: P<Pat>,
1214+
/// Type annotation, if any (otherwise the type will be inferred).
12101215
pub ty: Option<P<Ty>>,
12111216
/// Initializer expression to set the value, if any.
12121217
pub init: Option<P<Expr>>,
12131218
pub hir_id: HirId,
12141219
pub span: Span,
12151220
pub attrs: ThinVec<Attribute>,
1221+
/// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop
1222+
/// desugaring. Otherwise will be `Normal`.
12161223
pub source: LocalSource,
12171224
}
12181225

1219-
/// Represents a single arm of a `match` expression.
1226+
/// Represents a single arm of a `match` expression, e.g.
1227+
/// `<pats> (if <guard>) => <body>`.
12201228
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
12211229
pub struct Arm {
12221230
pub attrs: HirVec<Attribute>,
1231+
/// Multiple patterns can be combined with `|`
12231232
pub pats: HirVec<P<Pat>>,
1233+
/// Optional guard clause.
12241234
pub guard: Option<Guard>,
1235+
/// The expression the arm evaluates to if this arm matches.
12251236
pub body: P<Expr>,
12261237
}
12271238

0 commit comments

Comments
 (0)