Challenge 24: Verify Vec Part2 safety with Kani#599
Open
v3risec wants to merge 1 commit into
Open
Conversation
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.
Summary
This PR adds Kani-based verification artifacts for
Veciterator-related functions inlibrary/alloc/src/vec/for Challenge 24: Verify the safety of Vec functions part 2.The change introduces:
IntoIter::__iterator_get_unchecked#[cfg(kani)]for all Challenge 24 listedVeciterator entriesVechelpers for allocated, ZST, unbounded, and reserve-sensitive casesIntoIter::fold,IntoIter::try_fold,ExtractIf::next, andVec::extend_desugaredVerification Coverage Report
Coverage: 22 / 22 Challenge 24 entries targeted
IntoItercoverage includes:as_sliceas_mut_sliceforget_allocation_drop_remaininginto_vecdequenextsize_hintadvance_bynext_chunkfoldtry_fold__iterator_get_uncheckednext_backadvance_back_bydropAdditional
Veciterator-path coverage includes:ExtractIf::nextSpecExtend::spec_extendforIntoIterSpecExtend::spec_extendforslice::IterSpecFromElem::from_elemfori8SpecFromElem::from_elemforu8SpecFromElem::from_elemfor()SpecFromIter::from_iterSpecFromIterNested::from_iterdefault pathApproach
The verification strategy combines executable harnesses with targeted contracts and loop annotations:
IntoIter::__iterator_get_uncheckedrequiring the unchecked index to be within the iterator's remaining range.#[kani::proof]harnesses for each Challenge 24 target, using symbolicVecconstruction across integer types,usize/isize, unit/ZSTs, and arrays.cfg(kani).Scope assumptions
Tis represented through a broad set of concrete instantiations used by the harness macros.__iterator_get_uncheckedharness enforces the contract precondition directly because Kani currently cannot resolve the generic trait method target forproof_for_contract.Verification
All added Challenge 24 harnesses pass locally with Kani.
Resolves #285
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.