Skip to content

Commit 28644cd

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

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
@@ -816,6 +816,9 @@ pub struct MacroDef {
816816
pub legacy: bool,
817817
}
818818

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

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

1220-
/// Represents a single arm of a `match` expression.
1227+
/// Represents a single arm of a `match` expression, e.g.
1228+
/// `<pats> (if <guard>) => <body>`.
12211229
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
12221230
pub struct Arm {
12231231
pub attrs: HirVec<Attribute>,
1232+
/// Multiple patterns can be combined with `|`
12241233
pub pats: HirVec<P<Pat>>,
1234+
/// Optional guard clause.
12251235
pub guard: Option<Guard>,
1236+
/// The expression the arm evaluates to if this arm matches.
12261237
pub body: P<Expr>,
12271238
}
12281239

0 commit comments

Comments
 (0)