Enum rustc_middle::mir::terminator::TerminatorKind
source · [−]pub enum TerminatorKind<'tcx> {
Show 15 variants
Goto {
target: BasicBlock,
},
SwitchInt {
discr: Operand<'tcx>,
switch_ty: Ty<'tcx>,
targets: SwitchTargets,
},
Resume,
Abort,
Return,
Unreachable,
Drop {
place: Place<'tcx>,
target: BasicBlock,
unwind: Option<BasicBlock>,
},
DropAndReplace {
place: Place<'tcx>,
value: Operand<'tcx>,
target: BasicBlock,
unwind: Option<BasicBlock>,
},
Call {
func: Operand<'tcx>,
args: Vec<Operand<'tcx>>,
destination: Option<(Place<'tcx>, BasicBlock)>,
cleanup: Option<BasicBlock>,
from_hir_call: bool,
fn_span: Span,
},
Assert {
cond: Operand<'tcx>,
expected: bool,
msg: AssertMessage<'tcx>,
target: BasicBlock,
cleanup: Option<BasicBlock>,
},
Yield {
value: Operand<'tcx>,
resume: BasicBlock,
resume_arg: Place<'tcx>,
drop: Option<BasicBlock>,
},
GeneratorDrop,
FalseEdge {
real_target: BasicBlock,
imaginary_target: BasicBlock,
},
FalseUnwind {
real_target: BasicBlock,
unwind: Option<BasicBlock>,
},
InlineAsm {
template: &'tcx [InlineAsmTemplatePiece],
operands: Vec<InlineAsmOperand<'tcx>>,
options: InlineAsmOptions,
line_spans: &'tcx [Span],
destination: Option<BasicBlock>,
cleanup: Option<BasicBlock>,
},
}Variants
Goto
Fields
target: BasicBlockBlock should have one successor in the graph; we jump there.
SwitchInt
Fields
discr: Operand<'tcx>The discriminant value being tested.
switch_ty: Ty<'tcx>The type of value being tested.
This is always the same as the type of discr.
FIXME: remove this redundant information. Currently, it is relied on by pretty-printing.
targets: SwitchTargetsOperand evaluates to an integer; jump depending on its value
to one of the targets, and otherwise fallback to otherwise.
Resume
Indicates that the landing pad is finished and unwinding should
continue. Emitted by build::scope::diverge_cleanup.
Abort
Indicates that the landing pad is finished and that the process should abort. Used to prevent unwinding for foreign items.
Return
Indicates a normal return. The return place should have been filled in before this executes. This can occur multiple times in different basic blocks.
Unreachable
Indicates a terminator that can never be reached.
Drop
Drop the Place.
DropAndReplace
Drop the Place and assign the new value over it. This ensures
that the assignment to P occurs even if the destructor for
place unwinds. Its semantics are best explained by the
elaboration:
BB0 {
DropAndReplace(P <- V, goto BB1, unwind BB2)
}becomes
BB0 {
Drop(P, goto BB1, unwind BB2)
}
BB1 {
// P is now uninitialized
P <- V
}
BB2 {
// P is now uninitialized -- its dtor panicked
P <- V
}Note that DropAndReplace is eliminated as part of the ElaborateDrops pass.
Call
Fields
func: Operand<'tcx>The function that’s being called.
args: Vec<Operand<'tcx>>Arguments the function is called with. These are owned by the callee, which is free to modify them. This allows the memory occupied by “by-value” arguments to be reused across function calls without duplicating the contents.
destination: Option<(Place<'tcx>, BasicBlock)>Destination for the return value. If some, the call is converging.
cleanup: Option<BasicBlock>Cleanups to be done if the call unwinds.
from_hir_call: booltrue if this is from a call in HIR rather than from an overloaded
operator. True for overloaded function call.
fn_span: SpanThis Span is the span of the function, without the dot and receiver
(e.g. foo(a, b) in x.foo(a, b)
Block ends with a call of a function.
Assert
Fields
cond: Operand<'tcx>expected: boolmsg: AssertMessage<'tcx>target: BasicBlockcleanup: Option<BasicBlock>Jump to the target if the condition has the expected value, otherwise panic with a message and a cleanup target.
Yield
Fields
value: Operand<'tcx>The value to return.
resume: BasicBlockWhere to resume to.
resume_arg: Place<'tcx>The place to store the resume argument in.
drop: Option<BasicBlock>Cleanup to be done if the generator is dropped at this suspend point.
A suspend point.
GeneratorDrop
Indicates the end of the dropping of a generator.
FalseEdge
Fields
real_target: BasicBlockThe target normal control flow will take.
imaginary_target: BasicBlockA block control flow could conceptually jump to, but won’t in practice.
A block where control flow only ever takes one real path, but borrowck needs to be more conservative.
FalseUnwind
Fields
real_target: BasicBlockThe target normal control flow will take.
unwind: Option<BasicBlock>The imaginary cleanup block link. This particular path will never be taken
in practice, but in order to avoid fragility we want to always
consider it in borrowck. We don’t want to accept programs which
pass borrowck only when panic=abort or some assertions are disabled
due to release vs. debug mode builds. This needs to be an Option because
of the remove_noop_landing_pads and abort_unwinding_calls passes.
A terminator for blocks that only take one path in reality, but where we reserve the right to unwind in borrowck, even if it won’t happen in practice. This can arise in infinite loops with no function calls for example.
InlineAsm
Fields
template: &'tcx [InlineAsmTemplatePiece]The template for the inline assembly, with placeholders.
operands: Vec<InlineAsmOperand<'tcx>>The operands for the inline assembly, as Operands or Places.
options: InlineAsmOptionsMiscellaneous options for the inline assembly.
line_spans: &'tcx [Span]Source spans for each line of the inline assembly code. These are used to map assembler errors back to the line in the source code.
destination: Option<BasicBlock>Destination block after the inline assembly returns, unless it is diverging (InlineAsmOptions::NORETURN).
cleanup: Option<BasicBlock>Cleanup to be done if the inline assembly unwinds. This is present if and only if InlineAsmOptions::MAY_UNWIND is set.
Block ends with an inline assembly block. This is a terminator since inline assembly is allowed to diverge.
Implementations
sourceimpl<'tcx> TerminatorKind<'tcx>
impl<'tcx> TerminatorKind<'tcx>
pub fn if_(
tcx: TyCtxt<'tcx>,
cond: Operand<'tcx>,
t: BasicBlock,
f: BasicBlock
) -> TerminatorKind<'tcx>
pub fn successors(&self) -> Successors<'_>
pub fn successors_mut(&mut self) -> SuccessorsMut<'_>
pub fn unwind(&self) -> Option<&Option<BasicBlock>>
pub fn unwind_mut(&mut self) -> Option<&mut Option<BasicBlock>>
pub fn as_switch(&self) -> Option<(&Operand<'tcx>, Ty<'tcx>, &SwitchTargets)>
pub fn as_goto(&self) -> Option<BasicBlock>
sourceimpl<'tcx> TerminatorKind<'tcx>
impl<'tcx> TerminatorKind<'tcx>
sourcepub fn fmt_head<W: Write>(&self, fmt: &mut W) -> Result
pub fn fmt_head<W: Write>(&self, fmt: &mut W) -> Result
Writes the “head” part of the terminator; that is, its name and the data it uses to pick the successor basic block, if any. The only information not included is the list of possible successors, which may be rendered differently between the text and the graphviz format.
sourcepub fn fmt_successor_labels(&self) -> Vec<Cow<'static, str>>
pub fn fmt_successor_labels(&self) -> Vec<Cow<'static, str>>
Returns the list of labels for the edges to the successor basic blocks.
Trait Implementations
sourceimpl<'tcx> Clone for TerminatorKind<'tcx>
impl<'tcx> Clone for TerminatorKind<'tcx>
sourcefn clone(&self) -> TerminatorKind<'tcx>
fn clone(&self) -> TerminatorKind<'tcx>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<'tcx> Debug for TerminatorKind<'tcx>
impl<'tcx> Debug for TerminatorKind<'tcx>
sourceimpl<'tcx, __D: TyDecoder<'tcx>> Decodable<__D> for TerminatorKind<'tcx>
impl<'tcx, __D: TyDecoder<'tcx>> Decodable<__D> for TerminatorKind<'tcx>
sourceimpl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for TerminatorKind<'tcx>
impl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for TerminatorKind<'tcx>
sourceimpl<'tcx> Hash for TerminatorKind<'tcx>
impl<'tcx> Hash for TerminatorKind<'tcx>
sourceimpl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for TerminatorKind<'tcx>
impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for TerminatorKind<'tcx>
fn hash_stable(
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)
sourceimpl<'tcx> PartialEq<TerminatorKind<'tcx>> for TerminatorKind<'tcx>
impl<'tcx> PartialEq<TerminatorKind<'tcx>> for TerminatorKind<'tcx>
sourcefn eq(&self, other: &TerminatorKind<'tcx>) -> bool
fn eq(&self, other: &TerminatorKind<'tcx>) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &TerminatorKind<'tcx>) -> bool
fn ne(&self, other: &TerminatorKind<'tcx>) -> bool
This method tests for !=.
impl<'tcx> StructuralPartialEq for TerminatorKind<'tcx>
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for TerminatorKind<'tcx>
impl<'tcx> !Send for TerminatorKind<'tcx>
impl<'tcx> !Sync for TerminatorKind<'tcx>
impl<'tcx> Unpin for TerminatorKind<'tcx>
impl<'tcx> !UnwindSafe for TerminatorKind<'tcx>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Ctxt, T> DepNodeParams<Ctxt> for T where
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Ctxt, T> DepNodeParams<Ctxt> for T where
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
pub default fn fingerprint_style() -> FingerprintStyle
sourcepub default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
pub default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous). Read more
pub default fn to_debug_str(&self, Ctxt) -> String
sourcepub default fn recover(
Ctxt,
&DepNode<<Ctxt as DepContext>::DepKind>
) -> Option<T>
pub default fn recover(
Ctxt,
&DepNode<<Ctxt as DepContext>::DepKind>
) -> Option<T>
This method tries to recover the query key from the given DepNode,
something which is needed when forcing DepNodes during red-green
evaluation. The query system will only call this method if
fingerprint_style() is not FingerprintStyle::Opaque.
It is always valid to return None here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read more
sourceimpl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<'a, T> Captures<'a> for T where
T: ?Sized,
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 96 bytes
Size for each variant:
Goto: 7 bytesSwitchInt: 87 bytesResume: 0 bytesAbort: 0 bytesReturn: 0 bytesUnreachable: 0 bytesDrop: 31 bytesDropAndReplace: 55 bytesCall: 87 bytesAssert: 95 bytesYield: 55 bytesGeneratorDrop: 0 bytesFalseEdge: 11 bytesFalseUnwind: 11 bytesInlineAsm: 71 bytes