pub enum Stmt {
Show 21 variants
Nop,
Expr(Expr),
Let {
object: ObjectId,
init: Expr,
explicit: bool,
},
Vla(Box<VlaDef>),
Cleanup(Box<CleanupDef>),
Block(Vec<Stmt>),
If {
cond: Expr,
then_branch: Box<Stmt>,
else_branch: Option<Box<Stmt>>,
},
While {
id: LoopId,
cond: Expr,
body: Box<Stmt>,
range: SourceRange,
},
DoWhile {
id: LoopId,
body: Box<Stmt>,
cond: Expr,
range: SourceRange,
},
For {
id: LoopId,
init: Vec<Stmt>,
cond: Option<Expr>,
step: Option<Expr>,
body: Box<Stmt>,
range: SourceRange,
},
Switch(Box<Switch>),
SwitchTree(Box<SwitchTree>),
Case {
switch: SwitchId,
value: Option<CaseRange>,
body: Box<Stmt>,
range: SourceRange,
},
Label {
id: LabelId,
body: Box<Stmt>,
range: SourceRange,
},
Region(Box<Region>),
Goto {
id: LabelId,
range: SourceRange,
},
GotoPtr {
target: Expr,
range: SourceRange,
},
Break {
target: BreakTarget,
range: SourceRange,
},
Continue {
id: LoopId,
range: SourceRange,
},
Return {
value: Option<Expr>,
range: SourceRange,
},
Asm(Box<AsmStmt>),
}Expand description
A typed statement.
Variants§
Nop
The null statement.
Expr(Expr)
An expression evaluated for its side effects.
Let
A local variable definition. C leaves an uninitialised local indeterminate; the initialiser here is a zero of the right type in that case, so that the generated Rust never reads uninitialised memory.
Fields
explicit: boolWhether the source wrote an initialiser at all.
It decides what happens when the definition has to be hoisted out
of the block it was written in — out of a switch body, or to the
top of a function lowered into a control-flow graph.
The hoisted definition zero-initialises; only an initialiser the
program actually wrote has to run again where it was written.
Vla(Box<VlaDef>)
The definition of a variable length array (C99 6.7.5.2).
It is a Stmt::Let with two bindings instead of one, because the
object needs storage whose size is only known here; see VlaDef.
Cleanup(Box<CleanupDef>)
T x __attribute__((cleanup(f))); — the registration of the call that
runs when x goes out of scope. See CleanupDef.
Block(Vec<Stmt>)
A compound statement.
If
if (cond) then_branch else else_branch
Fields
While
while (cond) body
Fields
range: SourceRangeWhere the statement was written.
DoWhile
do body while (cond);
Fields
range: SourceRangeWhere the statement was written.
For
for (init; cond; step) body
Fields
range: SourceRangeWhere the statement was written.
Switch(Box<Switch>)
switch (scrutinee) { … }
SwitchTree(Box<SwitchTree>)
switch (scrutinee) body, with the body left as a statement tree.
Only produced in CFG mode, where the labels stay where
they were written — a case inside a nested statement (Duff’s device)
is simply another edge into the loop the CFG builds.
Case
case value: or default: inside a Stmt::SwitchTree.
Fields
range: SourceRangeWhere the label was written.
Label
label: body — a goto target.
Fields
range: SourceRangeWhere the label was written.
Region(Box<Region>)
A labelled region a goto leaves, in the structured lowering.
Only produced by regions, which is where the shape
and the two kinds are described. A Stmt::Goto inside one names its
label and becomes break or continue accordingly.
Goto
goto label;
GotoPtr
GNU’s computed goto *e;, whose operand is a label
address.
Only produced in CFG mode, which is the only mode a function containing one is lowered in.
Break
break;
Fields
target: BreakTargetWhat the break leaves.
range: SourceRangeWhere the statement was written.
Continue
continue;
Fields
range: SourceRangeWhere the statement was written.
Return
return; or return expr;
Asm(Box<AsmStmt>)
GNU inline assembly, mapped onto core::arch::asm!; see AsmStmt.
It has no control flow of its own (asm goto is refused), so the
control-flow graph carries it as a simple statement.