Fix std overrides in crates where std is used as a feature#2194
Merged
zhassan-aws merged 4 commits intomodel-checking:mainfrom Feb 8, 2023
Merged
Fix std overrides in crates where std is used as a feature#2194zhassan-aws merged 4 commits intomodel-checking:mainfrom
zhassan-aws merged 4 commits intomodel-checking:mainfrom
Conversation
danielsn
reviewed
Feb 7, 2023
| fn foo() { | ||
| let x: i32 = kani::any(); | ||
| let y = 0; | ||
| std::debug_assert!(x + y == x, "Message"); |
Contributor
There was a problem hiding this comment.
Should we also have a test where the assertion fails?
Contributor
Author
There was a problem hiding this comment.
I don't think this is necessary, since we're mainly checking that compilation goes through. There are many other tests that check for failing assertions.
celinval
approved these changes
Feb 7, 2023
Contributor
celinval
left a comment
There was a problem hiding this comment.
I'm worried that this is getting out of control. We should investigate a more robust solution.
Thanks for the quick fix though.
danielsn
reviewed
Feb 7, 2023
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.
Description of changes:
Kani's std overrides relied on creating an alias for
core::assertup front to use for error checking in various macros (assert,panic, etc.). Creating the alias upfront doesn't work properly in crates withno_stdwherestdis used as a feature (see #2187). This PR updates the std overrides to usecore::assertdirectly when anstdfeature is enabled.Resolved issues:
Resolves #2187
Related RFC:
Optional #ISSUE-NUMBER.
Call-outs:
To avoid code duplication, I tried creating a macro that calls
__kani__workaround_core_assertundernot(std)andcore::assertotherwise. However, I ran into the same error reported in #2187.Testing:
How is this change tested? Added one test
Is this a refactor change? No
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.