Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zhassan-aws committed Mar 7, 2023
1 parent a9d9c3f commit 5d74b68
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
15 changes: 0 additions & 15 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,7 @@ macro_rules! assert {
// strategy, which is tracked in
// https://github.com/model-checking/kani/issues/692
if false {
#[cfg(not(feature = "std"))]
__kani__workaround_core_assert!(true, $($arg)+);
// In a `no_std` setting where `std` is used as a feature, defining
// the alias for `core::assert` doesn't work, so we need to use
// `core::assert` directly (see
// https://github.com/model-checking/kani/issues/2187)
#[cfg(feature = "std")]
core::assert!(true, $($arg)+);
}
}};
}
Expand Down Expand Up @@ -172,11 +165,7 @@ macro_rules! unreachable {
// handle.
($fmt:expr, $($arg:tt)*) => {{
if false {
#[cfg(not(feature = "std"))]
__kani__workaround_core_assert!(true, $fmt, $($arg)+);
// See comment in `assert` definition
#[cfg(feature = "std")]
core::assert!(true, $fmt, $($arg)+);
}
kani::panic(concat!("internal error: entered unreachable code: ",
stringify!($fmt, $($arg)*)))}};
Expand Down Expand Up @@ -208,11 +197,7 @@ macro_rules! panic {
// `panic!("Error: {}", code);`
($($arg:tt)+) => {{
if false {
#[cfg(not(feature = "std"))]
__kani__workaround_core_assert!(true, $($arg)+);
// See comment in `assert` definition
#[cfg(feature = "std")]
core::assert!(true, $($arg)+);
}
kani::panic(stringify!($($arg)+));
}};
Expand Down
9 changes: 9 additions & 0 deletions tests/cargo-kani/chrono_dep/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "chrono_dep"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chrono = "=0.4.19"
1 change: 1 addition & 0 deletions tests/cargo-kani/chrono_dep/main.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERIFICATION:- SUCCESSFUL
10 changes: 10 additions & 0 deletions tests/cargo-kani/chrono_dep/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! This test checks that the Kani compiler handles chrono crate which was
//! previously failing due to https://github.com/model-checking/kani/issues/1949
#[kani::proof]
fn main() {
assert!(1 + 1 == 2);
}
2 changes: 1 addition & 1 deletion tests/cargo-kani/no_std/foo.expected
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERIFICATION:- SUCCESSFUL
error: cannot find macro `__kani__workaround_core_assert` in this scope
5 changes: 3 additions & 2 deletions tests/cargo-kani/no_std/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! This test makes sure Kani handles assert in no_std environment which was
//! previous failing (see https://github.com/model-checking/kani/issues/2187)
//! This test checks that Kani handles assert in no_std environment which
//! currently doesn't work:
//! https://github.com/model-checking/kani/issues/2187)
#![no_std]

Expand Down

0 comments on commit 5d74b68

Please sign in to comment.