-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't write contracts for a method defined inside more than one impl block #3773
Comments
I did some debugging. The function that throws the error: kani/kani-compiler/src/kani_middle/attributes.rs Lines 479 to 488 in db1c5fe
calls kani/kani-compiler/src/kani_middle/attributes.rs Lines 235 to 249 in db1c5fe
which finds the |
This example is based on the real NonZero implementation in the standard library. A closer rendition of how NonZero is actually instantiated would be: struct NonZero<T>(T);
macro_rules! nonzero_integer {
(
Self = $Ty:ident,
Primitive = $signedness:ident $Int:ty
) => {
pub type $Ty = NonZero<$Int>;
impl NonZero<$Int> {
#[kani::requires(true)]
fn unchecked_mul(self, x: $Int) {}
}
};
(
Self = $Ty:ident,
Primitive = unsigned $Int:ty
) => {
nonzero_integer! {
Self = $Ty,
Primitive = unsigned $Int
}
};
(
Self = $Ty:ident,
Primitive = signed $Int:ty
) => {
nonzero_integer! {
Self = $Ty,
Primitive = signed $Int
}
}
}
nonzero_integer! {
Self = UnsignedNonZero,
Primitive = unsigned u32
}
nonzero_integer! {
Self = SignedNonZero,
Primitive = signed i32
}
#[kani::proof_for_contract(NonZero::unchecked_mul)]
fn verify_unchecked_mul() {
let x: NonZero<i32> = NonZero(-1);
x.unchecked_mul(-2);
} but this ends up expanding to the minimal example I originally posted. |
I tried this code:
using the following command line invocation:
with Kani version: 0.56
I expected to see this happen: verification success
Instead, this happened: explanation
The text was updated successfully, but these errors were encountered: