Repository navigation
Reject ordinary stubs of contract targets - #5211
feliperodri merged 1 commit into
Conversation
feliperodri
left a comment
There was a problem hiding this comment.
Thanks for picking up #5206. Rejecting the combination while resolving the harness stubs is the right place: the error comes before codegen and replaces the internal "Failed to find contract closure" failure. I tried a few more shapes locally: a trait method target (<S as T>::m, which crashes on main) and a generic target (gen::<u8>) are both rejected with the new message; a repeated stub_verified reports once; and malformed contract paths are still reported only once. The function-contract, stubbing and UI suites, clippy and fmt pass.
Two optional suggestions: the error currently points at the harness function, and pointing at the #[kani::stub] attribute (with a note on the contract attribute) would make it easier to act on; and since harness_stub_map now also reports conflicts, a line in its doc comment would help. Approving.
On main, combining
#[kani::stub(f, g)]with#[kani::proof_for_contract(f)]or#[kani::stub_verified(f)]in the same harness fails withFailed to find contract closure __kani_recursion_check_f. The ordinary stub replaces the body containingf's contract instrumentation.Kani now rejects these combinations while resolving the harness's stubs, with an error naming the function and conflicting attributes. Ordinary stubs of other functions and reverse-direction stubs remain supported.
Resolves #5206.
Testing:
tests/ui/function-contracts/ordinary_stub_target_conflictchecks both errors, andtests/expected/function-contract/ordinary_stub_different_targetcovers a stub of another function and a reverse-direction stub under each attribute. CI in my fork: regression on Ubuntu 22.04, Ubuntu 24.04, Ubuntu 24.04 ARM and macOS 15 Intel, documentation, perf, benchcomp, LLBC, format, Clippy and Cargo Deny passed. The macOS 15 job did not get a runner, and Ubuntu 22.04 passed on a rerun after the intermittentcodegen_cachefailure addressed by #5207.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
Disclosure: this change and description were prepared with the help of AI assistants.