Skip to content

LLBC backend: generic functions with trait bounds abort translation #5047

Open

Description

@feliperodri

A generic function with a trait bound aborts the LLBC backend, on main and with #5045:

pub fn dup<T: Clone>(x: &T) -> (T, T) {
    (x.clone(), x.clone())
}

#[kani::proof]
fn main() {
    let v: u32 = kani::any();
    let _ = dup(&v);
}

kani test.rs -Zlean panics with Expect free type var id in translate_generic_args (mir_to_ullbc/mod.rs), reached from translate_fn_ptr while translating a call.

Behind it is the larger gap: a trait method called on a generic type (x.clone() with T: Clone) can only be translated with a trait reference, the way Charon emits TraitMethod calls with the function's trait clauses. The backend doesn't translate trait clauses or trait references, so #5045 makes such calls report call to trait method ... with generic arguments instead of crashing, but they still don't translate. This blocks proofs about any generic code with bounds, which is most generic code.

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

    Z-Kani CompilerIssues that require some changes to the compiler[E] Unsupported ConstructAdd support to an unsupported construct[F] CrashKani crashed

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions