Skip to content

Commit cf76024

Browse files
author
Yoshiki Takashima
authored
Added --all-features flag. (rust-lang#1532)
* Added --all-features flag. * Made the doc more detailed.
1 parent 298002d commit cf76024

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

kani-driver/src/args.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ pub struct KaniArgs {
114114
/// Kani will only compile the crate. No verification will be performed
115115
#[structopt(long, hidden_short_help(true))]
116116
pub only_codegen: bool,
117+
/// Compiles Kani harnesses in all features of all packages selected on the command-line.
118+
#[structopt(long)]
119+
pub all_features: bool,
117120
/// Run Kani on all packages in the workspace.
118121
#[structopt(long)]
119122
pub workspace: bool,

kani-driver/src/call_cargo.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ impl KaniSession {
5252
args.push("build".into());
5353
}
5454

55+
if self.args.all_features {
56+
args.push("--all-features".into());
57+
}
58+
5559
if self.args.workspace {
5660
args.push("--workspace".into());
5761
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
[package]
5+
name = "feature-flag"
6+
version = "0.1.0"
7+
edition = "2021"
8+
9+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10+
11+
[features]
12+
A = []
13+
B = []
14+
15+
[dependencies]
16+
17+
[package.metadata.kani.flags]
18+
all-features = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3 successfully verified harnesses
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! 3 proof harnesses, 2 of them are feature-gated.
5+
6+
#[kani::proof]
7+
fn check_proof() {
8+
assert!(1 == 1);
9+
}
10+
11+
#[cfg(feature = "A")]
12+
#[kani::proof]
13+
fn check_proof_a() {
14+
assert!(2 == 2);
15+
}
16+
17+
#[cfg(feature = "B")]
18+
#[kani::proof]
19+
fn check_proof_b() {
20+
assert!(3 == 3);
21+
}

0 commit comments

Comments
 (0)