pub enum Terminator {
Jump {
target: BlockId,
range: SourceRange,
},
Branch {
cond: Expr,
then_blk: BlockId,
else_blk: BlockId,
},
IndirectJump {
target: Expr,
blocks: Vec<BlockId>,
range: SourceRange,
},
Switch {
value: Expr,
cases: Vec<(CaseRange, BlockId)>,
default: BlockId,
range: SourceRange,
},
Return {
value: Option<Expr>,
range: SourceRange,
},
Unreachable,
}Expand description
How a BasicBlock ends.
Variants§
Jump
Control moves to another block.
Branch
Control moves to one of two blocks depending on a condition.
Fields
IndirectJump
GNU’s computed goto *e: control moves to the block whose number the
pointer holds.
The blocks it can enter are the ones of every label whose address the
function took, which is what keeps them reachable, numbered and
unmerged; see Cfg::labels. The generated code stores the number in
the state variable and goes round the dispatch again, so a value that
is not one of them lands on the unreachable!() arm — which is the
undefined behaviour C already had.
Fields
range: SourceRangeWhere the statement was written.
Switch
A switch dispatch.
Fields
range: SourceRangeWhere the statement was written.
Return
The function returns.
Unreachable
Control never gets here.
Only reachable through a bug in this module, and emitted as
unreachable!() so that such a bug is loud rather than silent.