Repository navigation
Fix NonZero TryFrom out-of-range harnesses and add missing conversions - #811
Open
fromtaoyuanhsinchuuuu wants to merge 1 commit into
Open
fromtaoyuanhsinchuuuu wants to merge 1 commit into
fromtaoyuanhsinchuuuu wants to merge 1 commit into
Conversation
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.
Fixes two verification coverage gaps in
core::convert::numfor Challenge 14 (TryFrom<NonZero<_>>):#[kani::should_panic]check_nonzero_int_try_from_nonzero_int_should_panicharness ingenerate_nonzero_int_try_from_nonzero_int_harness!(which previously admittedv == 0, panicking inNonZero::new(x_inner).unwrap()beforetry_fromwas called and missing UB-free wrong-Okmutants) with a plain#[kani::proof]harnesscheck_nonzero_int_try_from_nonzero_int_out_of_range. It checks non-emptiness of the out-of-range domain, samplesv != 0outside[$target::MIN, $target::MAX], records akani::covernon-vacuity witness, constructsNonZero::new(x_inner).unwrap(), and assertsNonZero::<$target>::try_from(x).is_err().TryFrom<NonZero<_>>harness instantiations (u8 => i8, all 11 fromusize, and all 11 fromisize) with#[cfg(target_pointer_width = "16" / "32" / "64")]fallible/infallible splits so all 97impl_nonzero_int_try_from_nonzero_int!conversions are verified for both in-range and out-of-range behavior.231harnesses inconvert::num::verifypassing,0failures) and confirmed via mutation testing that all86out-of-range harnesses fail iftry_fromreturnsOkinstead ofErr.Resolves #800
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.