You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Requested feature: Officially stabilize the Arbitrary trait
Use case: Crates that define public types could implement Arbitrary for those type so that downstream crates can more easily use them or implement Arbitrary for types containing them.
Thanks for the request, it helps us prioritize. In this case, there are some pretty tricky design problems to think through, so it's probably not going to be short-term, unfortunately.
Oh, nice that's even better since it supports a fuzzer too! But now I feel like there are way too many fuzzing traits. There's quickcheck::Arbitrary and I'm pretty sure I've seen another one somewhere. Would be great if there was just one but that's a different topic.
Hey @Kixunil, just wanted to chime in that there is also a way to create instances for Arbitrary in a library and expose them, though it is a bit roundabout and relies on internal details in how Kani operates. So this should not be considered a reliable approach, but if you need it it is available.
When this code is compiled with kani, wether that be in your workspace or in a dependency, the cfg(kani) will have been set and also the kani library will be implicitly in scope (as if you had done extern crate kani at the top).
You could even push this to crates.io and it should work to depend on it.
Activity
tedinski commentedon Dec 22, 2022
Thanks for the request, it helps us prioritize. In this case, there are some pretty tricky design problems to think through, so it's probably not going to be short-term, unfortunately.
One possible short-term solution is to use Bolero and
bolero-generator[-derive]. This lets you depend on those crates (which are published normally on crates.io) and we did write a recent blog post about using Bolero with Kani: https://model-checking.github.io/kani-verifier-blog/2022/10/27/using-kani-with-the-bolero-property-testing-framework.htmlDo you think this might work for you?
Kixunil commentedon Dec 22, 2022
Oh, nice that's even better since it supports a fuzzer too! But now I feel like there are way too many fuzzing traits. There's
quickcheck::Arbitraryand I'm pretty sure I've seen another one somewhere. Would be great if there was just one but that's a different topic.JustusAdam commentedon Sep 22, 2023
Hey @Kixunil, just wanted to chime in that there is also a way to create instances for
Arbitraryin a library and expose them, though it is a bit roundabout and relies on internal details in how Kani operates. So this should not be considered a reliable approach, but if you need it it is available.When this code is compiled with kani, wether that be in your workspace or in a dependency, the
cfg(kani)will have been set and also thekanilibrary will be implicitly in scope (as if you had doneextern crate kaniat the top).You could even push this to crates.io and it should work to depend on it.
JustusAdam commentedon Sep 22, 2023
In terms of a common trait there is an
arbitrarycrate on creates.io https://crates.io/crates/arbitrary, created byrust-fuzz. Kani could support that by "simply" overwriting theArbitraryimplfor basic types likeusizevia GOTO hook.Kixunil commentedon Sep 22, 2023
Yeah, my point was to have something that could be included in a serious library. But goo to know if I ever have a less serious one. :)