Skip to content

Autoharness: types that should be supported (no Arbitrary, trait objects, fn pointers, HashMap, Option<&T>, Pin, tuples with &str) #5137

Description

@feliperodri

Part of #4887 (Missing Arbitrary umbrella). Related: #4890 (requires bounded arguments), #4888 (generic function with no candidate type), #3832 (autoharness tracking).

This is a list of input types that AutoHarness cannot generate today and that we think should be supported. Each entry has a minimal reproducer and the skip reason Kani prints. Found while evaluating cargo kani autoharness on about 110 crates.

Tested with Kani built from main at 47689dc (Kani 0.68.0, CBMC 6.11.0, nightly-2026-10-23).

Types that still fail in every mode

Modes: default; --bounded-arguments; --constructor-args. All three were tried for each entry.

  1. Arrays of a type without Arbitrary ([T; N])

    pub struct NoArb { pub x: u8 }
    pub fn array_of_user(a: [NoArb; 2]) -> u8 { a[0].x }

    Missing Arbitrary implementation for argument(s) a: [NoArb; 2]
    Reason: arrays are common in protocol and embedded code. Generating [T; N] element-wise when T can be generated would cover them.

  2. Boxed trait objects (Box<dyn Trait>)

    pub fn boxed_dyn(d: Box<dyn Fn() -> u8>) -> u8 { d() }

    Missing Arbitrary implementation for argument(s) d: std::boxed::Box<dyn std::ops::Fn() -> u8>
    Reason: callbacks and plugin APIs. A clear "trait object: not supported" reason would also help if no implementation is planned.

  3. Reference to a trait object (&dyn Trait)

    pub fn dyn_ref(d: &dyn std::fmt::Debug) -> usize { format!("{:?}", d).len() }

    Missing Arbitrary implementation for argument(s) d: &dyn std::fmt::Debug

  4. Function pointers (fn(T) -> U)

    pub fn fn_ptr(f: fn(u8) -> u8) -> u8 { f(1) }

    Missing Arbitrary implementation for argument(s) f: fn(u8) -> u8
    Inconsistency: pub fn closure_arg(f: impl Fn(u8) -> u8) -> u8 { f(1) } is supported (through nondet_fn1). A function pointer could use the same model. This may be the cheapest entry on the list.

  5. HashMap / HashSet

    pub fn map_arg(m: std::collections::HashMap<u8, u8>) -> usize { m.len() }

    Missing Arbitrary implementation for argument(s) m: std::collections::HashMap<u8, u8>
    Reason: common in every real crate. Related: Internal compiler error on HashMap/HashSet (RandomState::new): rustc_metadata panics on AnonConst #5101 (ICE on RandomState::new). The RandomState path reaches a getrandom syscall, so a fixed-hasher model would be needed.

  6. References inside Option (Option<&T>)

    pub fn option_ref(o: Option<&u8>) -> u8 { o.copied().unwrap_or(0) }

    Missing Arbitrary implementation for argument(s) o: std::option::Option<&u8>
    Reason: lookup and iterator APIs. This also needs the bounded model that &T already gets in some cases.

  7. Pin<&mut T>

    pub fn pinned(p: std::pin::Pin<&mut u8>) -> u8 { *p.into_ref() }

    Missing Arbitrary implementation for argument(s) p: std::pin::Pin<&mut u8>
    Reason: async and runtime code.

Types that only need the bounded model extended

  1. A &str inside a tuple ((&str, u8))
    pub fn tuple_str(t: (&str, u8)) -> u8 { t.1 }
    Missing Arbitrary implementation for argument(s) t: (&str, u8)
    --bounded-arguments handles a top-level &str, &[T], String and Vec, but not the same types inside a tuple, struct or Option. This is the composition case for Autoharness umbrella: requires bounded arguments (RequiresBoundedArguments) #4890.

Already supported (for reference, so nobody duplicates the work)

  • &str, String, &[u8], &mut [u8], Vec<u8>: with --bounded-arguments.
  • Primitive types (u8, u128, char, f64), Rc<u8>, RefCell<u8>, Cell<u8>, PhantomData<u8>, Duration, Result<u8, E> where E is a crate-local type, and crate-local structs and enums: selected by default in our probe.
  • impl Fn(u8) -> u8 arguments.

Request

Please decide, per entry, one of: support it, or record in the skip reason why no implementation is planned (as the umbrella's "common cases" section asks). We can split this into one issue per type if you prefer the umbrella's per-type convention.

Reproduce: put the functions above in src/lib.rs of a crate, then run cargo kani autoharness --list -Z autoharness -Z unstable-options, and again with --bounded-arguments and --constructor-args. Kani prints the skip reason for each function.


This was found with Kani in an experiment where AI agents used the Kani agent plugin (#5059) to evaluate Kani autoharness on popular crates. The text was written with AI assistance; the reproducers were run by hand on the Kani build named above.

Activity

  1. added this to the Autoharness milestone on Nov 7, 2026
  2. added theissue type on Nov 7, 2026
  3. changed the issue type fromtoon Nov 7, 2026
  4. added
    Z-Autoharness
    on Nov 7, 2026
  5. feliperodri commented on Nov 7, 2026

    @feliperodri
    MemberAuthor
  6. added
    [C] Feature / Enhancement
    [E] Unsupported Construct
    on Nov 10, 2026
  7. changed the issue type fromtoon Nov 10, 2026
  8. self-assigned this
    on Nov 10, 2026
  9. added
    T-High Priority
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

T-High PriorityZ-Autoharness[C] Feature / Enhancement[E] Unsupported Construct

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions