Repository navigation
Conversation
…rguments Generate `CharArraySearcher<'_, N>`, `CharArrayRefSearcher<'_, '_, N>` and `CharSliceSearcher<'_, '_>` arguments (by value, `&` or `&mut`) when `--bounded-arguments` is passed. The new `kani_core` models build the searcher with `Pattern::into_searcher` over a bounded nondeterministic haystack (the string bound) and a nondeterministic needle (`[char; N]`, or a `&[char]` of up to the slice bound for `CharSliceSearcher`), then advance it a nondeterministic number of steps from each end so that searchers in partially advanced states are also generated. `multi_char_eq_searcher_kind` identifies the three types by definition path and is shared by the eligibility check and harness generation. The searchers' `Debug::fmt` methods are verified as ordinary functions rather than through the formatting-trait model, since the searcher needs harness-owned storage. Also factor the storage-array construction of the slice/str branches into `build_any_array_storage_ref`, and document the new argument types and the extended scope of `--slice-bound`/`--string-bound`.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #4811. Part of #4879.
With
--bounded-arguments, autoharness can now generateCharArraySearcher<'_, N>,CharArrayRefSearcher<'_, '_, N>andCharSliceSearcher<'_, '_>arguments, by value,&or&mut. These are the searchers for[char; N],&[char; N]and&[char]patterns incore::str::pattern.Changes
kani_coremodels build the searcher through the publicPattern::into_searcherAPI over a bounded nondeterministic haystack (fromany_str_ref, string bound) and a nondeterministic needle ([char; N], or a&[char]of up to the slice bound forCharSliceSearcher). They then advance it a nondeterministic number of steps from each end, so that searchers in partially advanced states are also generated.multi_char_eq_searcher_kindidentifies the three types by definition path and is shared by the eligibility check and harness generation.Debug::fmtmethods are verified as ordinary functions rather than through the formatting-trait model, since the searcher needs harness-owned storage.build_any_array_storage_ref.--slice-bound/--string-boundhelp text document the new argument types.Testing
cargo_autoharness_multichareq_searcher: 10 harnesses, 9 pass and 1 fails as expected, and all 90 cover properties are satisfied. It takes about 7 minutes with--string-bound 4 --slice-bound 4. I kept these bounds because smaller ones exclude 4-byte UTF-8 characters or leave some covers unreachable, but happy to lower them if CI time is a concern.cargo fmt --checkandcargo clippy --workspace --tests -- -D warningspass.Results on verify-std
--bounded-arguments, all 27 functions listed in Autoharness: support theMultiCharEqsearcher types incore::str::pattern#4811 now get harnesses (9 per searcher type). The other 23 functions inpattern.rs(CharPredicateSearcher,CharSearcher,StrSearcher) are still skipped and are out of scope here.char::from_u32_uncheckedandhint::unreachable_unchecked, caused by Autoharness: &str arguments can be invalid UTF-8 under verify-std, causing spurious failures #5030 (&strfromany_str_refcan be invalid UTF-8 under verify-std). CBMC traces forCharArraySearcher::haystackandCharArraySearcher::nextconfirm this: the haystack bytes are mis-validated byfrom_utf8, and the failures occur while the model advances the searcher, before the function under test runs. Fornext, the call graph shows theunreachable_uncheckedcheck is reachable only from UTF-8 decoding. The other 6 fail on the same two checks and very likely share the cause, but I did not trace them individually.Notes
docs/src/reference/experimental/autoharness.md. I'll resolve the conflict in whichever merges second.encode_utf8.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.