Skip to content

Cannot verify a constant function if crate has effect feature enabled #3258

@celinval

Description

@celinval

I tried this code:

#![feature(effects)]

#[kani::requires(kani::mem::can_dereference(arg))]
const unsafe fn dummy<T>(arg: *const T) -> T {
    std::ptr::read(arg)
}

#[kani::proof_for_contract(dummy)]
fn check() {
    unsafe { dummy(&kani::any::<u8>()) };
}

using the following command line invocation:

kani -Z function-contracts -Z mem-predicates contract.rs

with Kani version:

I expected to see this happen: Verification should pass;

Instead, this happened: Compilation fails

error: mismatch in the number of generic parameters: original function/method `dummy` takes 2 generic parameters(s), stub `dummy_recursion_wrapper_8b0f77` takes 1
  --> constant.rs:15:1
   |
15 | #[kani::proof_for_contract(dummy)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `kani::proof_for_contract` (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    [C] BugThis is a bug. Something isn't working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions