Skip to content

Commit 00c648d

Browse files
authored
[Breaking change] Make kani::check private (#3614)
In the previous release, we added a deprecation warning to `kani::check` which was incorrectly exposed in our crate interface. Make this private and remove the deprecation tag. Resolves #3561 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent ab39455 commit 00c648d

File tree

5 files changed

+28
-62
lines changed

5 files changed

+28
-62
lines changed

library/kani/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#![feature(ptr_metadata)]
2020
#![feature(f16)]
2121
#![feature(f128)]
22-
// Need to add this since we are deprecating `kani::check`. Remove this when we remove that API.
23-
#![allow(deprecated)]
2422

2523
// Allow us to use `kani::` to access crate features.
2624
extern crate self as kani;

library/kani_core/src/lib.rs

Lines changed: 27 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ macro_rules! kani_lib {
4242
pub use kani_core::*;
4343
kani_core::kani_intrinsics!(core);
4444
kani_core::generate_arbitrary!(core);
45-
kani_core::check_intrinsic!();
4645

4746
pub mod mem {
4847
kani_core::kani_mem!(core);
@@ -59,10 +58,6 @@ macro_rules! kani_lib {
5958
kani_core::kani_intrinsics!(std);
6059
kani_core::generate_arbitrary!(std);
6160

62-
kani_core::check_intrinsic! {
63-
msg="This API will be made private in future releases.", vis=pub
64-
}
65-
6661
pub mod mem {
6762
kani_core::kani_mem!(std);
6863
}
@@ -462,51 +457,35 @@ macro_rules! kani_intrinsics {
462457

463458
/// Stub the body with its contract.
464459
pub const REPLACE: Mode = 3;
465-
}
466-
};
467-
}
468460

469-
#[macro_export]
470-
macro_rules! check_intrinsic {
471-
($(msg=$msg:literal, vis=$vis:vis)?) => {
472-
/// Creates a non-fatal property with the specified condition and message.
473-
///
474-
/// This check will not impact the program control flow even when it fails.
475-
///
476-
/// # Example:
477-
///
478-
/// ```no_run
479-
/// let x: bool = kani::any();
480-
/// let y = !x;
481-
/// kani::check(x || y, "ORing a boolean variable with its negation must be true");
482-
/// kani::check(x == y, "A boolean variable is always different than its negation");
483-
/// kani::cover!(true, "This should still be reachable");
484-
/// ```
485-
///
486-
/// # Deprecated
487-
///
488-
/// This function was meant to be internal only, and it was added to Kani's public interface
489-
/// by mistake. Thus, it will be made private in future releases.
490-
/// Instead, we recommend users to either use `assert` or `cover` to create properties they
491-
/// would like to verify.
492-
///
493-
/// See <https://github.com/model-checking/kani/issues/3561> for more details.
494-
#[cfg(not(feature = "concrete_playback"))]
495-
#[inline(never)]
496-
#[rustc_diagnostic_item = "KaniCheck"]
497-
// TODO: Remove the `#![allow(deprecated)]` inside kani's crate once this is made private.
498-
$(#[deprecated(since="0.55.0", note=$msg)])?
499-
$($vis)? const fn check(cond: bool, msg: &'static str) {
500-
let _ = cond;
501-
let _ = msg;
502-
}
461+
/// Creates a non-fatal property with the specified condition and message.
462+
///
463+
/// This check will not impact the program control flow even when it fails.
464+
///
465+
/// # Example:
466+
///
467+
/// ```no_run
468+
/// let x: bool = kani::any();
469+
/// let y = !x;
470+
/// kani::check(x || y, "ORing a boolean variable with its negation must be true");
471+
/// kani::check(x == y, "A boolean variable is always different than its negation");
472+
/// kani::cover!(true, "This should still be reachable");
473+
/// ```
474+
///
475+
#[cfg(not(feature = "concrete_playback"))]
476+
#[inline(never)]
477+
#[rustc_diagnostic_item = "KaniCheck"]
478+
pub(crate) const fn check(cond: bool, msg: &'static str) {
479+
let _ = cond;
480+
let _ = msg;
481+
}
503482

504-
#[cfg(feature = "concrete_playback")]
505-
#[inline(never)]
506-
#[rustc_diagnostic_item = "KaniCheck"]
507-
$(#[deprecated(since="0.55.0", note=$msg)])?
508-
$($vis)? const fn check(cond: bool, msg: &'static str) {
509-
assert!(cond, "{}", msg);
483+
#[cfg(feature = "concrete_playback")]
484+
#[inline(never)]
485+
#[rustc_diagnostic_item = "KaniCheck"]
486+
pub(crate) const fn check(cond: bool, msg: &'static str) {
487+
assert!(cond, "{}", msg);
488+
}
510489
}
511490
};
512491
}

library/kani_core/src/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ macro_rules! kani_mem {
327327

328328
/// A helper to assert `is_initialized` to use it as a part of other predicates.
329329
fn assert_is_initialized<T: ?Sized>(ptr: *const T) -> bool {
330-
super::check(
330+
super::internal::check(
331331
is_initialized(ptr),
332332
"Undefined Behavior: Reading from an uninitialized pointer",
333333
);

tests/ui/check_deprecated/deprecated_warning.expected

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/ui/check_deprecated/deprecated_warning.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)