pub enum CastKind {
PointerExposeProvenance,
PointerWithExposedProvenance,
PointerCoercion(PointerCoercion, CoercionSource),
IntToInt,
FloatToInt,
FloatToFloat,
IntToFloat,
PtrToPtr,
FnPtrToPtr,
Transmute,
}
Variants§
PointerExposeProvenance
An exposing pointer to address cast. A cast between a pointer and an integer type, or
between a function pointer and an integer type.
See the docs on expose_provenance
for more details.
PointerWithExposedProvenance
An address-to-pointer cast that picks up an exposed provenance.
See the docs on with_exposed_provenance
for more details.
PointerCoercion(PointerCoercion, CoercionSource)
Pointer related casts that are done by coercions. Note that reference-to-raw-ptr casts are
translated into &raw mut/const *r
, i.e., they are not actually casts.
The following are allowed in AnalysisPhase::Initial
as they’re needed for borrowck,
but after that are forbidden (including in all phases of runtime MIR):
Both are runtime nops, so should be CastKind::PtrToPtr
instead in runtime MIR.
IntToInt
FloatToInt
FloatToFloat
IntToFloat
PtrToPtr
FnPtrToPtr
Transmute
Reinterpret the bits of the input as a different type.
MIR is well-formed if the input and output types have different sizes, but running a transmute between differently-sized types is UB.
Allowed only in MirPhase::Runtime
; Earlier it’s a TerminatorKind::Call
.