Skip to content

Commit f6d3385

Browse files
Remove deprecated --enable-stubbing (rust-lang#3309)
Part of rust-lang#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 <88045115+zhassan-aws@users.noreply.github.com>
1 parent d926482 commit f6d3385

File tree

11 files changed

+28
-50
lines changed

11 files changed

+28
-50
lines changed

kani-driver/src/args/mod.rs

+18-23
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,6 @@ pub struct VerificationArgs {
282282
#[arg(long)]
283283
pub randomize_layout: Option<Option<u64>>,
284284

285-
/// Enable the stubbing of functions and methods.
286-
// TODO: Stubbing should in principle work with concrete playback.
287-
// <https://github.com/model-checking/kani/issues/1842>
288-
#[arg(
289-
long,
290-
hide_short_help = true,
291-
requires("enable_unstable"),
292-
conflicts_with("concrete_playback")
293-
)]
294-
enable_stubbing: bool,
295-
296285
/// Enable Kani coverage output alongside verification result
297286
#[arg(long, hide_short_help = true)]
298287
pub coverage: bool,
@@ -345,8 +334,7 @@ impl VerificationArgs {
345334

346335
/// Is experimental stubbing enabled?
347336
pub fn is_stubbing_enabled(&self) -> bool {
348-
self.enable_stubbing
349-
|| self.common_args.unstable_features.contains(UnstableFeature::Stubbing)
337+
self.common_args.unstable_features.contains(UnstableFeature::Stubbing)
350338
|| self.is_function_contracts_enabled()
351339
}
352340
}
@@ -579,6 +567,13 @@ impl ValidateArgs for VerificationArgs {
579567
--output-format=old.",
580568
));
581569
}
570+
if self.concrete_playback.is_some() && self.is_stubbing_enabled() {
571+
// Concrete playback currently does not work with contracts or stubbing.
572+
return Err(Error::raw(
573+
ErrorKind::ArgumentConflict,
574+
"Conflicting options: --concrete-playback isn't compatible with stubbing.",
575+
));
576+
}
582577
if self.concrete_playback.is_some() && self.jobs() != Some(1) {
583578
// Concrete playback currently embeds a lot of assumptions about the order in which harnesses get called.
584579
return Err(Error::raw(
@@ -606,10 +601,6 @@ impl ValidateArgs for VerificationArgs {
606601
}
607602
}
608603

609-
if self.enable_stubbing {
610-
print_deprecated(&self.common_args, "--enable-stubbing", "-Z stubbing");
611-
}
612-
613604
if self.concrete_playback.is_some()
614605
&& !self.common_args.unstable_features.contains(UnstableFeature::ConcretePlayback)
615606
{
@@ -880,14 +871,18 @@ mod tests {
880871

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

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

887-
// `--enable-stubbing` cannot be called with `--concrete-playback`
888-
let err =
889-
parse_unstable_enabled("--enable-stubbing --harness foo --concrete-playback=print")
890-
.unwrap_err();
880+
// `-Z stubbing` cannot be called with `--concrete-playback`
881+
let res = parse_unstable_disabled(
882+
"--harness foo --concrete-playback=print -Z concrete-playback -Z stubbing",
883+
)
884+
.unwrap();
885+
let err = res.validate().unwrap_err();
891886
assert_eq!(err.kind(), ErrorKind::ArgumentConflict);
892887
}
893888

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//
4-
//! This tests that the `--enable-stubbing` and `--harness` arguments flow from `kani-driver` to `kani-compiler`.
4+
//! This tests that enabling stubbing and using `--harness` arguments flow from
5+
//! `kani-driver` to `kani-compiler`.
56
67
#[kani::proof]
78
fn main() {}

tests/expected/function-stubbing-no-harness/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//
4-
// kani-flags: --harness foo --enable-unstable --enable-stubbing
4+
// kani-flags: --harness foo -Z stubbing
55
//
66
//! This tests whether we detect missing harnesses during stubbing.
77

tests/expected/stubbing-ambiguous-path/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//
4-
// kani-flags: --harness main --enable-unstable --enable-stubbing
4+
// kani-flags: --harness main -Z stubbing
55
//
66
//! This tests that we raise an error if a path in a `kani::stub` attribute can
77
//! resolve to multiple functions.

tests/ui/function-stubbing-error/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//
4-
// kani-flags: --harness main --enable-unstable --enable-stubbing
4+
// kani-flags: --harness main -Z stubbing
55
//
66
//! This tests whether we detect syntactically misformed `kani::stub` annotations.
77

tests/ui/stubbing/deprecated-enable-stable/deprecated.rs

-16
This file was deleted.

tests/ui/stubbing/deprecated-enable-stable/expected

-2
This file was deleted.

tests/ui/stubbing/invalid-path/invalid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//
4-
// kani-flags: --harness invalid_stub --enable-unstable --enable-stubbing
4+
// kani-flags: --harness invalid_stub -Z stubbing
55

66
pub mod mod_a {
77
use crate::mod_b::noop;
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//
4-
// kani-flags: --harness main --enable-unstable --enable-stubbing
4+
// kani-flags: --harness main -Z stubbing
55
//
6-
//! This tests that the `--enable-stubbing` and `--harness` arguments flow from `kani-driver` to `kani-compiler`.
6+
//! This tests that enabling stubbing and `--harness` argument flow from `kani-driver` to `kani-compiler`.
77
88
#[kani::proof]
99
fn main() {}

tests/ui/stubbing/stubbing-trait-validation/trait_mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//
4-
// kani-flags: --harness harness --enable-unstable --enable-stubbing
4+
// kani-flags: --harness harness -Z stubbing
55
//
66
//! This tests that we catch trait mismatches between the stub and the original
77
//! function/method. In particular, this tests the case when the program is

tests/ui/stubbing/stubbing-type-validation/type_mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//
4-
// kani-flags: --harness harness --enable-unstable --enable-stubbing
4+
// kani-flags: --harness harness -Z stubbing
55
//
66
//! This tests that we catch type mismatches between the stub and the original
77
//! function/method.

0 commit comments

Comments
 (0)