Skip to content

-Z uninit-checks: pointers to niche-encoded enums (e.g. TryReserveErrorKind) are unsupported #5165

Description

@feliperodri

With -Z uninit-checks, every Vec/VecDeque growth path fails with

Kani currently doesn't support checking memory initialization for pointers to `collections::TryReserveErrorKind. Cannot determine layout for an Enum with niche encoding of type collections::TryReserveErrorKind

TryReserveErrorKind (CapacityOverflow | AllocError { layout, non_exhaustive }) uses the niche in Layout's alignment. It's reached from RawVec::grow_amortized/try_reserve, so reserve, push, append, resize_with etc. all hit it. In verify-rust-std #681 it fails 4 harnesses directly.

The #3300 checklist has "enums with variants that have different padding"; this is the niche-encoded case, which is likely the more common one in std (Option<NonNull<_>>, Result<_, TryReserveError>, Option<Layout>). The same harnesses also report "Interaction between raw pointers and unions is not yet supported", which #3300 already tracks ("Unions can serve as a pointee of raw pointers").

Reproducer (confirmed on c5e65fd; verifies without the flag):

extern crate alloc;
#[kani::proof]
fn try_reserve() {
    let mut v: alloc::vec::Vec<u8> = alloc::vec::Vec::new();
    let n: usize = kani::any();
    kani::assume(n <= 4);
    let _ = v.try_reserve(n);
}

With -Z uninit-checks this reports the niche-enum check above, plus unsupported caller_location (#374), integer_max and cold_path (#5164) and "pointer to unallocated memory".

Activity

  1. added
    [E] Unsupported Construct
    Z-UnstableFeature
    on Nov 17, 2026
  2. self-assigned this
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Z-UnstableFeature[E] Unsupported Construct

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions