Verify contracts/stubs for generic types with multiple inherent implementations #3829
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Extends Kani's contracts/stubbing logic to handle simple paths with generic arguments. I'll explain the changes commit-by-commit:
Commit 690ba97: Error for multiple implementations
Prior to this PR, given the code from #3773:
When resolving the target, Kani would return the first
unchecked_mul
implementation that it found for NonZero. If that happens to be theu32
implementation, then we get an error later that the targetNonZero::unchecked_mul
isn't reachable from the harness, which is confusing because the harness does callunchecked_mul
.The real problem is that the target needs to specify which implementation it wants to verify, so now we throw this error:
Commit 62b66de: Path resolution for simple paths with generic arguments
If the user took our suggestion and changed their proof for contract to be
NonZero::<i32>::unchecked_mul
, they would still get the same error. Thesyn::Path
is this:Kani's path resolution would skip over the
PathArguments
for the base type NonZero, so it would still try to findNonZero::unchecked_mul
and run into the same problem. So, this commit adds abase_path_args
field to ourPath
representation to store these arguments, which we use to select the specified implementation.Resolves #3773
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.