-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Contracts: Can't include non-Copy
types in contract
#3027
Comments
Yes, this makes sense. Why does The problem is not that contracts in general need |
But also I think we could probably avoid actually renaming |
Oh, I see. Then let me check if I can pass a reference instead. Thank you! |
If I pass the argument by reference then
I've pushed the commit to the branch kani-contracts-crash. |
The current method for creating the modifies wrapper requires changing the `ensures` clause to have `_renamed` variables which are unsafe copies of the original function arguments. This causes issues with regards to some possible tests as in #3239. This change removes the `_renamed` variables and instead simply changes the modifies clauses within the replace to unsafely dereference the pointer to modify the contents of it unsafely, condensing all instances of unsafe Rust into a single location. Resolves #3239 Resolves #3026 May affect #3027. In my attempt to run this example with slight modification to fit the current implementation, I got the error `CBMC appears to have run out of memory. You may want to rerun your proof in an environment with additional memory or use stubbing to reduce the size of the code the verifier reasons about.` This suggests that the compilation is working appropriately but the test case is just too large for CBMC. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. Co-authored-by: Matias Scharager <mscharag@amazon.com>
When trying out the contracts feature (from Kani 0.46.0) in one of my projects, I got the following errors:
I've opened #3026 for improving the error message, but anyway it's clear to me that it's asking for
Expr
to implementCopy
. In my case,Expr
is anenum
defined as follows:Here, the usage of
Box<...>
prevents me from directly deriving theCopy
trait. As far as I know, theCopy
trait cannot be implemented forBox<...>
because we'd end up with multiple boxes referencing the same value.Can you recommend a good workaround for this? I think it should be possible to have a custom
impl for Copy
that behaves likeClone
, but then I'm not sure it'd work with the contracts implementation (and I'd expect performance issues even if it did).If you'd like to reproduce the error or anything else, the complete program can be found in the kani-contracts branch of my project. Once it's cloned, simply run
cargo kani
.The text was updated successfully, but these errors were encountered: