-
Notifications
You must be signed in to change notification settings - Fork 127
Ensure that contract closures are FnOnce #4151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3878527
Ensure that contract closures are FnOnce
77cb015
Wrap modifies closure
577dba4
Merge branch 'model-checking:main' into force_fn_once
vonaka e7c3983
Handle force_fn during the contract pass
f00d4ec
Merge branch 'model-checking:main' into force_fn_once
vonaka 0d57745
Merge branch 'model-checking:main' into force_fn_once
vonaka 187b616
Add tests for contracts for functions returning mut ref
cc92920
Merge branch 'model-checking:main' into force_fn_once
vonaka ea4adc1
Merge branch 'force_fn_once' of github.com:vonaka/kani into force_fn_…
bc801cf
Merge branch 'main' into force_fn_once
vonaka 8ddd683
Update tests
5508ba7
Add a bit of explanations
b2c19f7
Undo updates of submodules.
a892cfe
Merge branch 'model-checking:main' into force_fn_once
vonaka e19f510
Update tests
cf8846a
Make force_fn_onces unreachable
be40caa
Undo updates of compiler and core
8dad0cd
Update comments
006afe5
update module documentation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
1 change: 1 addition & 0 deletions
1
tests/expected/function-contract/mutable-references/ensures_with_two_mut_refs_fail.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
error[E0501]: cannot borrow value as immutable because previous closure requires unique access |
15 changes: 15 additions & 0 deletions
15
tests/expected/function-contract/mutable-references/ensures_with_two_mut_refs_fail.rs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Z function-contracts | ||
|
||
tautschnig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[kani::ensures(|result| **result == 42 && *result == n)] | ||
#[kani::modifies(n)] | ||
fn forty_two(n: &mut u8) -> &mut u8 { | ||
*n = 42; | ||
n | ||
} | ||
|
||
#[kani::proof_for_contract(forty_two)] | ||
fn forty_two_harness() { | ||
forty_two(&mut kani::any()); | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/expected/function-contract/mutable-references/return_mut_ref.expected
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
assertion\ | ||
- Status: UNREACHABLE\ | ||
- Description: "attempt to divide by zero"\ | ||
in function divide_by | ||
|
||
assertion\ | ||
- Status: SUCCESS\ | ||
- Description: "|result| **result <= a"\ | ||
in function divide_by | ||
|
||
VERIFICATION:- SUCCESSFUL | ||
tautschnig marked this conversation as resolved.
Show resolved
Hide resolved
|
16 changes: 16 additions & 0 deletions
16
tests/expected/function-contract/mutable-references/return_mut_ref.rs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Z function-contracts | ||
|
||
tautschnig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[kani::requires(*b > 0 && *b < a)] | ||
#[kani::ensures(|result| **result <= a)] | ||
#[kani::modifies(b)] | ||
fn divide_by(a: u8, b: &mut u8) -> &mut u8 { | ||
*b = a / *b; | ||
b | ||
} | ||
|
||
#[kani::proof_for_contract(divide_by)] | ||
fn divide_by_harness() { | ||
divide_by(kani::any(), &mut kani::any()); | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.