generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 142
Add implementation for the #[kani::should_panic] attribute
#2315
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 all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7748b2d
Add implementation for the `#[kani::should-panic]` attribute
adpaco-aws 45496be
Update `ui` test
adpaco-aws 610b2b8
Rename some `should_panic` to `panic_outcome`
adpaco-aws 94321da
Update `expected` files
adpaco-aws cf7cace
Rename `PanicOutcome` and variants as `FailedProperties`
adpaco-aws 99a6bc8
"for now" -> "currently"
adpaco-aws e7c9550
Avoid `Option` type for `FailedProperties`
adpaco-aws df9960a
"for now" -> "currently" for kani::proof
adpaco-aws 1683c13
Redo comments for `FailedProperties`
adpaco-aws d1e1293
Add assertion in `no-panics` test
adpaco-aws 73d0966
Merge branch 'main' into add-should-panic
adpaco-aws 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| error: custom attribute panicked | ||
| #[kani::proof] does not take any arguments for now | ||
| #[kani::proof] does not take any arguments currently | ||
|
|
||
| error: custom attribute panicked | ||
| #[kani::proof] cannot be applied to async functions that take inputs for now |
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,4 @@ | ||
| ** 2 of 2 failed\ | ||
| Failed Checks: panicked on the `if` branch! | ||
| Failed Checks: panicked on the `else` branch! | ||
| VERIFICATION:- SUCCESSFUL (encountered one or more panics as 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,15 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| //! Checks that verfication passes when `#[kani::should_panic]` is used and all | ||
| //! failures encountered are panics. | ||
|
|
||
| #[kani::proof] | ||
| #[kani::should_panic] | ||
| fn check() { | ||
| if kani::any() { | ||
| panic!("panicked on the `if` branch!"); | ||
| } else { | ||
| panic!("panicked on the `else` branch!"); | ||
| } | ||
| } |
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,2 @@ | ||
| error: only one '#[kani::should_panic]' attribute is allowed per harness | ||
| error: aborting due to previous error |
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,9 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| //! Checks that `#[kani::should_panic]` can only be used once. | ||
|
|
||
| #[kani::proof] | ||
| #[kani::should_panic] | ||
| #[kani::should_panic] | ||
| fn check() {} |
1 change: 1 addition & 0 deletions
1
tests/ui/should-panic-attribute/multiple-harnesses-panic/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 @@ | ||
| Complete - 3 successfully verified harnesses, 0 failures, 3 total. |
23 changes: 23 additions & 0 deletions
23
tests/ui/should-panic-attribute/multiple-harnesses-panic/test.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,23 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| //! Checks that the verification summary printed at the end considers all | ||
| //! harnesses as "successfully verified". | ||
|
|
||
| #[kani::proof] | ||
| #[kani::should_panic] | ||
| fn harness1() { | ||
| panic!("panicked on `harness1`!"); | ||
| } | ||
|
|
||
| #[kani::proof] | ||
| #[kani::should_panic] | ||
| fn harness2() { | ||
| panic!("panicked on `harness2`!"); | ||
| } | ||
|
|
||
| #[kani::proof] | ||
| #[kani::should_panic] | ||
| fn harness3() { | ||
| panic!("panicked on `harness3`!"); | ||
| } |
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,4 @@ | ||
| - Status: SUCCESS\ | ||
| - Description: "assertion failed: 1 + 1 == 2" | ||
| ** 0 of 1 failed | ||
| VERIFICATION:- FAILED (encountered no panics, but at least one was 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 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| //! Checks that verfication fails when `#[kani::should_panic]` is used and no | ||
| //! panics are encountered. | ||
|
|
||
| #[kani::proof] | ||
| #[kani::should_panic] | ||
| fn check() { | ||
| assert!(1 + 1 == 2); | ||
| } |
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,8 @@ | ||
| overflow.undefined-shift.1\ | ||
| - Status: FAILURE\ | ||
| - Description: "shift distance too large" | ||
| Failed Checks: attempt to shift left with overflow | ||
| Failed Checks: panicked on the `1` arm! | ||
| Failed Checks: panicked on the `0` arm! | ||
| Failed Checks: shift distance too large | ||
| VERIFICATION:- FAILED (encountered failures other than panics, which were unexpected) |
23 changes: 23 additions & 0 deletions
23
tests/ui/should-panic-attribute/unexpected-failures/test.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,23 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| //! Checks that verfication fails when `#[kani::should_panic]` is used but not | ||
| //! all failures encountered are panics. | ||
|
|
||
| fn trigger_overflow() { | ||
| let x: u32 = kani::any(); | ||
| let _ = 42 << x; | ||
| } | ||
|
|
||
| #[kani::proof] | ||
| #[kani::should_panic] | ||
| fn check() { | ||
| match kani::any() { | ||
| 0 => panic!("panicked on the `0` arm!"), | ||
| 1 => panic!("panicked on the `1` arm!"), | ||
| _ => { | ||
| trigger_overflow(); | ||
| () | ||
| } | ||
| } | ||
| } |
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.