Skip to content

Commit

Permalink
Remove deprecated --enable-stubbing (#3309)
Browse files Browse the repository at this point in the history
Part of #2279 

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

---------

Co-authored-by: Zyad Hassan <[email protected]>
  • Loading branch information
celinval and zhassan-aws authored Jul 3, 2024
1 parent d926482 commit f6d3385
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 50 deletions.
41 changes: 18 additions & 23 deletions kani-driver/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,6 @@ pub struct VerificationArgs {
#[arg(long)]
pub randomize_layout: Option<Option<u64>>,

/// Enable the stubbing of functions and methods.
// TODO: Stubbing should in principle work with concrete playback.
// <https://github.com/model-checking/kani/issues/1842>
#[arg(
long,
hide_short_help = true,
requires("enable_unstable"),
conflicts_with("concrete_playback")
)]
enable_stubbing: bool,

/// Enable Kani coverage output alongside verification result
#[arg(long, hide_short_help = true)]
pub coverage: bool,
Expand Down Expand Up @@ -345,8 +334,7 @@ impl VerificationArgs {

/// Is experimental stubbing enabled?
pub fn is_stubbing_enabled(&self) -> bool {
self.enable_stubbing
|| self.common_args.unstable_features.contains(UnstableFeature::Stubbing)
self.common_args.unstable_features.contains(UnstableFeature::Stubbing)
|| self.is_function_contracts_enabled()
}
}
Expand Down Expand Up @@ -579,6 +567,13 @@ impl ValidateArgs for VerificationArgs {
--output-format=old.",
));
}
if self.concrete_playback.is_some() && self.is_stubbing_enabled() {
// Concrete playback currently does not work with contracts or stubbing.
return Err(Error::raw(
ErrorKind::ArgumentConflict,
"Conflicting options: --concrete-playback isn't compatible with stubbing.",
));
}
if self.concrete_playback.is_some() && self.jobs() != Some(1) {
// Concrete playback currently embeds a lot of assumptions about the order in which harnesses get called.
return Err(Error::raw(
Expand Down Expand Up @@ -606,10 +601,6 @@ impl ValidateArgs for VerificationArgs {
}
}

if self.enable_stubbing {
print_deprecated(&self.common_args, "--enable-stubbing", "-Z stubbing");
}

if self.concrete_playback.is_some()
&& !self.common_args.unstable_features.contains(UnstableFeature::ConcretePlayback)
{
Expand Down Expand Up @@ -880,14 +871,18 @@ mod tests {

#[test]
fn check_enable_stubbing() {
check_unstable_flag!("--enable-stubbing --harness foo", enable_stubbing);
let res = parse_unstable_disabled("--harness foo").unwrap();
assert!(!res.verify_opts.is_stubbing_enabled());

check_unstable_flag!("--enable-stubbing", enable_stubbing);
let res = parse_unstable_disabled("--harness foo -Z stubbing").unwrap();
assert!(res.verify_opts.is_stubbing_enabled());

// `--enable-stubbing` cannot be called with `--concrete-playback`
let err =
parse_unstable_enabled("--enable-stubbing --harness foo --concrete-playback=print")
.unwrap_err();
// `-Z stubbing` cannot be called with `--concrete-playback`
let res = parse_unstable_disabled(
"--harness foo --concrete-playback=print -Z concrete-playback -Z stubbing",
)
.unwrap();
let err = res.validate().unwrap_err();
assert_eq!(err.kind(), ErrorKind::ArgumentConflict);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/cargo-ui/stubbing-flag/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
//! This tests that the `--enable-stubbing` and `--harness` arguments flow from `kani-driver` to `kani-compiler`.
//! This tests that enabling stubbing and using `--harness` arguments flow from
//! `kani-driver` to `kani-compiler`.
#[kani::proof]
fn main() {}
2 changes: 1 addition & 1 deletion tests/expected/function-stubbing-no-harness/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// kani-flags: --harness foo --enable-unstable --enable-stubbing
// kani-flags: --harness foo -Z stubbing
//
//! This tests whether we detect missing harnesses during stubbing.
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/stubbing-ambiguous-path/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// kani-flags: --harness main --enable-unstable --enable-stubbing
// kani-flags: --harness main -Z stubbing
//
//! This tests that we raise an error if a path in a `kani::stub` attribute can
//! resolve to multiple functions.
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/function-stubbing-error/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// kani-flags: --harness main --enable-unstable --enable-stubbing
// kani-flags: --harness main -Z stubbing
//
//! This tests whether we detect syntactically misformed `kani::stub` annotations.
Expand Down
16 changes: 0 additions & 16 deletions tests/ui/stubbing/deprecated-enable-stable/deprecated.rs

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ui/stubbing/deprecated-enable-stable/expected

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/stubbing/invalid-path/invalid.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// kani-flags: --harness invalid_stub --enable-unstable --enable-stubbing
// kani-flags: --harness invalid_stub -Z stubbing

pub mod mod_a {
use crate::mod_b::noop;
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/stubbing/stubbing-flag/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// kani-flags: --harness main --enable-unstable --enable-stubbing
// kani-flags: --harness main -Z stubbing
//
//! This tests that the `--enable-stubbing` and `--harness` arguments flow from `kani-driver` to `kani-compiler`.
//! This tests that enabling stubbing and `--harness` argument flow from `kani-driver` to `kani-compiler`.
#[kani::proof]
fn main() {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// kani-flags: --harness harness --enable-unstable --enable-stubbing
// kani-flags: --harness harness -Z stubbing
//
//! This tests that we catch trait mismatches between the stub and the original
//! function/method. In particular, this tests the case when the program is
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// kani-flags: --harness harness --enable-unstable --enable-stubbing
// kani-flags: --harness harness -Z stubbing
//
//! This tests that we catch type mismatches between the stub and the original
//! function/method.
Expand Down

0 comments on commit f6d3385

Please sign in to comment.