Skip to content
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

Include --check-cfg=cfg(kani) in the rust flags to avoid a warning about an unknown cfg. #3187

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kani-driver/src/call_single_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl KaniSession {
"panic_abort_tests=yes",
"-Z",
"mir-enable-passes=-RemoveStorageMarkers",
"--check-cfg=cfg(kani)",
]
.map(OsString::from),
);
Expand Down
9 changes: 9 additions & 0 deletions tests/cargo-kani/unexpected_cfgs/Cargo.toml
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

[package]
name = "unexpected_cfgs"
version = "0.1.0"
edition = "2021"

[dependencies]
1 change: 1 addition & 0 deletions tests/cargo-kani/unexpected_cfgs/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERIFICATION:- SUCCESSFUL
19 changes: 19 additions & 0 deletions tests/cargo-kani/unexpected_cfgs/src/main.rs
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 checks that the `unexpected_cfgs` lint (enabled by default as of
// the 2024-05-05 toolchain) does not cause `cargo kani` to emit warnings when
// the code has `#[cfg(kani)]`. Kani avoids the warning by adding
// `--check-cfg=cfg(kani)` to the rust flags.

#![deny(unexpected_cfgs)]

fn main() {}

#[cfg(kani)]
mod kani_checks {
#[kani::proof]
fn check_unexpected_cfg() {
assert_eq!(1, 1);
}
}
Loading