Function rustc_const_eval::util::might_permit_raw_init::might_permit_raw_init
source · pub fn might_permit_raw_init<'tcx>(
tcx: TyCtxt<'tcx>,
ty: TyAndLayout<'tcx>,
kind: InitKind
) -> bool
Expand description
Determines if this type permits “raw” initialization by just transmuting some memory into an
instance of T
.
init_kind
indicates if the memory is zero-initialized or left uninitialized. We assume
uninitialized memory is mitigated by filling it with 0x01, which reduces the chance of causing
LLVM UB.
By default we check whether that operation would cause LLVM UB, i.e., whether the LLVM IR we
generate has UB or not. This is a mitigation strategy, which is why we are okay with accepting
Rust UB as long as there is no risk of miscompilations. The strict_init_checks
can be set to
do a full check against Rust UB instead (in which case we will also ignore the 0x01-filling and
to the full uninit check).