-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify all Kani attributes in all crate items upfront (#2536)
The Kani attributes were being lazily evaluated in some cases. We have also been handling duplicated attribute inconsistently. Instead, validate all the attributes upfront and print all the errors found. Also, for all attributes that multiple occurrences is redundant, we emit an error if user provides 2 or more.
- Loading branch information
Showing
11 changed files
with
181 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
error: failed to parse `#[kani::unstable]`: | ||
src/lib.rs\ | ||
error: failed to parse `#[kani::unstable]`: missing `feature` field\ | ||
lib.rs | ||
|\ | ||
9 | #[kani::unstable(reason = "just checking", issue = "<link>")]\ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ | ||
|\ | ||
= note: expected format: #[kani::unstable(feature="<IDENTIFIER>", issue="<ISSUE>", reason="<DESCRIPTION>")]\ | ||
= note: this error originates in the attribute macro `kani::unstable` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: failed to parse `#[kani::unstable]`: expected "key = value" pair, but found `feature("invalid_args")`\ | ||
lib.rs\ | ||
|\ | ||
| #[kani::unstable(feature("invalid_args"))]\ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ | ||
|\ | ||
= note: expected format: #[kani::unstable(feature="<IDENTIFIER>", issue="<ISSUE>", reason="<DESCRIPTION>")] | ||
|
||
error: failed to parse `#[kani::unstable]`: expected "key = value" pair, but found `feature`\ | ||
lib.rs\ | ||
|\ | ||
| #[kani::unstable(\ | ||
| ^^^^^^^^^^^^^^^^^^\ | ||
| #[kani::unstable(feature, issue)]\ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ | ||
|\ | ||
= note: expected format: #[kani::unstable(feature="<IDENTIFIER>", issue="<ISSUE>", reason="<DESCRIPTION>")]\ | ||
= note: this error originates in the attribute macro `kani::unstable` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
= note: expected format: #[kani::unstable(feature="<IDENTIFIER>", issue="<ISSUE>", reason="<DESCRIPTION>")] | ||
|
||
error: internal compiler error | ||
error: failed to parse `#[kani::unstable]`: expected "key = value" pair, but found `1010`\ | ||
lib.rs\ | ||
|\ | ||
| #[kani::unstable(1010)]\ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^\ | ||
|\ | ||
= note: expected format: #[kani::unstable(feature="<IDENTIFIER>", issue="<ISSUE>", reason="<DESCRIPTION>")] |
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,15 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
//! Check that invalid attributes are caught for all crate items | ||
#[kani::stub(invalid=opt)] | ||
pub fn unreachable_fn() {} | ||
|
||
// Also gracefully handle user embedded kanitool. | ||
#[kanitool::proof(invalid_argument)] | ||
#[kanitool::invalid::attribute] | ||
pub fn invalid_kanitool() {} | ||
|
||
#[kani::proof] | ||
pub fn valid_harness() {} |
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,27 @@ | ||
error: the `stub` attribute also requires the `#[kani::proof]` attribute\ | ||
attrs.rs | ||
|\ | ||
| #[kani::stub(invalid=opt)]\ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^\ | ||
| | ||
|
||
error: attribute `kani::stub` takes two path arguments; found 0\ | ||
attrs.rs | ||
|\ | ||
| #[kani::stub(invalid=opt)]\ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^\ | ||
| | ||
|
||
error: unknown attribute `invalid::attribute`\ | ||
attrs.rs\ | ||
|\ | ||
| #[kanitool::invalid::attribute]\ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: unexpected argument for `proof`\ | ||
attrs.rs\ | ||
|\ | ||
| #[kanitool::proof(invalid_argument)]\ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ | ||
| | ||
|
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
warning: duplicate attribute | ||
warning: Found the following unsupported constructs: | ||
- TerminatorKind::InlineAsm (1) | ||
Verification will fail if one or more of these constructs is reachable. | ||
|
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
warning: duplicate attribute\ | ||
main.rs:\ | ||
error: only one '#[kani::proof]' attribute is allowed per harness\ | ||
main.rs\ | ||
|\ | ||
| #[kani::proof]\ | ||
| ^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^\ | ||
|\ |