Skip to content

Autoharness: "no candidate type" skip message doesn't distinguish causes #4877

Description

@CYJ904

Requested feature

When autoharness can't instantiate a generic function, the skip message is the same regardless of the cause:

Generic Function: no candidate type (i32, u32, usize, u8, i64, u64, f64, f32, bool, char) satisfies the function's trait bounds

It would help if the message said which bound was unsatisfied, and why the search ended (no implementor, implementors filtered out, or the 256-query limit reached). In a kani autoharness --list run on verify-rust-std (x86_64 Linux), about 4,500 functions are skipped with this message, and right now there's no way to group them by cause.

Message construction: https://github.com/model-checking/kani/blob/4e31125fd/kani-compiler/src/kani_middle/codegen_units.rs#L1055-L1067

Test case

// Implementors exist but are filtered out (they carry a lifetime or type parameter)
pub trait ByteSource {
    fn byte_len(&self) -> usize;
}

impl<'a> ByteSource for &'a [u8] {
    fn byte_len(&self) -> usize {
        self.len()
    }
}

pub struct Wrapper<T>(pub T);

impl<T> ByteSource for Wrapper<T> {
    fn byte_len(&self) -> usize {
        core::mem::size_of::<T>()
    }
}

pub fn source_len<S: ByteSource>(s: S) -> usize {
    s.byte_len()
}

// No implementor at all
pub trait Unimplemented {
    fn value(&self) -> u8;
}

pub fn needs_unimplemented<T: Unimplemented>(t: T) -> u8 {
    t.value()
}

On current main (4e31125), cargo kani autoharness -Z autoharness --list skips both source_len and needs_unimplemented with exactly the message quoted above, even though they fail for different reasons.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [C] Feature / EnhancementA new feature request or enhancement to an existing feature.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions