Skip to main content

eval_array_len

Function eval_array_len 

Source
pub(crate) fn eval_array_len<'tcx>(
    tcx: TyCtxt<'tcx>,
    c: &Const<'tcx>,
) -> Option<u64>
Expand description

Resolve an array length const (ty::Const) to a concrete u64. Unlike try_to_target_usize, this also evaluates unevaluated const expressions (e.g. [MaybeUninit<K>; CAPACITY] where CAPACITY = 2 * B - 1), so the VM can allocate the array with its true element count instead of a collapsed zero-size fallback.