pub enum Stmt {
Let {
name: Ident,
mutable: bool,
ty: Option<TypeExpr>,
value: Expr,
span: Span,
},
Assign {
target: Expr,
value: Expr,
span: Span,
},
Expr {
expr: Expr,
span: Span,
has_semi: bool,
},
Return {
value: Option<Expr>,
span: Span,
},
While {
cond: Expr,
body: Block,
span: Span,
},
WhileLet {
pattern: Pattern,
value: Expr,
body: Block,
span: Span,
},
For {
var: Ident,
head: ForHead,
body: Block,
span: Span,
},
Break {
span: Span,
},
Continue {
span: Span,
},
}Expand description
A statement: let, assignment, return, while, break, continue,
or an expression used for its side effects (or as a block’s tail,
distinguished by has_semi on Stmt::Expr so the type checker can tell a
mid-block statement from a block’s value).
Variants§
Let
Assign
Assignment to a place expression: a path (a variable) or a field
access. Anything else as the target is rejected (V0002) before
this node is ever built.
Expr
An expression statement. has_semi is false only for a block-like
expression (if, a bare block) written without a trailing ; in
the middle of a block, not at its end.
Return
While
WhileLet
while let pattern = value { body } (M4 spec 2.4): value is
parsed in condition position, as while’s condition is.
For
for var in head { body } (spec 2.4). head is either a half-open
range or a Vec iterated element by element; the loop variable’s
type and whether the Vec case borrows or owns each element is the
type checker’s job (task 8).