Skip to main content

slice_invariants

Function slice_invariants 

Source
fn slice_invariants(
    genv: GlobalEnv<'_, '_>,
    elem_ty: &Ty,
    overflow_mode: OverflowMode,
) -> Vec<Invariant>
Expand description

All slices have 0 <= len <= usize::MAX, with the upper bound subject to overflow checking.

Also subject to overflow checking, slices have len * T::size_of() <= isize::MAX (see std::slice::from_raw_parts).

While this holds for all slices, the above condition reduces to true for ZST slices, so we omit it. Additionally, for ZST slices, the usize::MAX upper bound is redundant, so we omit it.