forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reject proof harnesses with arguments (rust-lang#2132)
- Change `#[kani::proof]` expansion so it doesn't include `#[no_mangle]` but includes `[allow(dead_code)]`. (rust-lang#661 and rust-lang#689). - Add a check for harnesses with arguments and merge the checks into one function (rust-lang#1919). Co-authored-by: Zyad Hassan <88045115+zhassan-aws@users.noreply.github.com>
- Loading branch information
1 parent
7f232fe
commit 0eb1fe8
Showing
9 changed files
with
128 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,17 @@ | ||
warning: Duplicate attribute\ | ||
invalid.rs:\ | ||
|\ | ||
| #[kani::proof]\ | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: Functions used as harnesses can not have any arguments.\ | ||
invalid.rs:\ | ||
|\ | ||
| #[kani::proof] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: The proof attribute cannot be applied to generic functions.\ | ||
invalid.rs:\ | ||
|\ | ||
| #[kani::proof]\ | ||
| ^^^^^^^^^^^^^^ |
This file contains 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,19 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// This test is to check Kani's error handling of invalid usages of the `proof` harness. | ||
// We also ensure that all errors and warnings are printed in one compilation. | ||
|
||
#[kani::proof] | ||
#[kani::proof] | ||
fn multiple_proof_annotations() {} | ||
|
||
#[kani::proof] | ||
fn proof_with_arg(arg: bool) { | ||
assert!(arg); | ||
} | ||
|
||
#[kani::proof] | ||
fn generic_harness<T: Default>() { | ||
let _ = T::default(); | ||
} |
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
warning: Only one '#[kani::proof]' allowed | ||
warning: Duplicate attribute |
This file contains 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 |
---|---|---|
@@ -1 +1,5 @@ | ||
warning: Only one '#[kani::proof]' allowed | ||
warning: Duplicate attribute\ | ||
main.rs:\ | ||
|\ | ||
| #[kani::proof]\ | ||
| ^^^^^^^^^^^^^^ |