-
Notifications
You must be signed in to change notification settings - Fork 89
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
Resolve trait methods during stubbing #1997
Comments
Adding the |
What if we create something like: #[kani::stub(trait_impl(Trait::function for Type), stub_funtion)] I.e.: The example would look like: #[kani::stub(trait_impl(A::bar for X), empty_debug)] |
I think it makes sense to use rust's syntax, e.g.
|
For sure it would, but per the issue description, the attribute expects a simple path. Thus, the type as trait syntax does not work. |
I don't think so. The name of the attribute needs to be a simple path, yes, but the contents of the attribute is arbitrary. The attribute contents is a Ideally we could just use |
After inspecting the rustc documentation a bit it may be possible to use existing infrastructure here. |
That would unblock this work. Thanks @JustusAdam for the update. |
I wonder if we can just use for parsing the attribute. We would also need to extend our name resolution to handle that case. In theory, users should be able to specify a simple path as well if there is no conflicting method name. |
@JustusAdam, your tip was great! I was able to retrieve a |
@celinval that depends. If you restrict it to non-parameterized traits, then the |
This is the first part needed for us to add support to stubbing trait implementations (#1997) and primitive types (#2646). After this change, we need to change stubs to accept a `FnResolution` instead of `FnDef`. We also need to find out how to retrieve methods of primitive types. 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: Zyad Hassan <[email protected]> Co-authored-by: Felipe R. Monteiro <[email protected]>
Right now, we do not support stubbing methods declared in traits. Consider this example:
It is currently not possible to stub
X
's implementation ofA::foo
,A::bar
, orB::bar
. To do so, we'd need to do two things.First, we'd need to come up with a way to refer to trait methods in our
kani::stub
attributes. Inrustc
, these are stringified as<X as B>::bar
, but paths in attribute arguments are not allowed to have spaces or symbols like<
and>
(they are simple paths). We could accept string arguments or come up with some other convention, e.g.:Second, we'd need to improve our path resolution algorithm to also search through trait implementations.
The text was updated successfully, but these errors were encountered: