forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an RMC crate and load it as part of rmc-rustc (rust-lang#597)
* Adding support to new rmc prelude definitions - Create an rmc crate (rust-lang#231). - Used rust compliant names for the functions (rust-lang#589). - Changed rmc-rustc to inject the rmc prelude as part of the compilation as well as other rmc configuration flags. - Added options to rmc-rustc to print binary path and flags so it can be used in other scripts. * Add a script to build rmc library * Update tests to use new injected prelude.
- Loading branch information
Showing
154 changed files
with
455 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
[package] | ||
name = "rmc" | ||
version = "0.1.0" | ||
edition = "2018" | ||
license = "MIT OR Apache-2.0" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
#![feature(rustc_attrs)] // Used for rustc_diagnostic_item. | ||
|
||
/// Creates an assumption that will be valid after this statement run. Note that the assumption | ||
/// will only be applied for paths that follow the assumption. If the assumption doesn't hold, the | ||
/// program will exit successfully. | ||
/// | ||
/// # Example: | ||
/// | ||
/// The code snippet below should never panic. | ||
/// | ||
/// ```rust | ||
/// let i : i32 = rmc::nondet(); | ||
/// rmc::assume(i > 10); | ||
/// if i < 0 { | ||
/// panic!("This will never panic"); | ||
/// } | ||
/// ``` | ||
/// | ||
/// The following code may panic though: | ||
/// | ||
/// ```rust | ||
/// let i : i32 = rmc::nondet(); | ||
/// assert!(i < 0, "This may panic and verification should fail."); | ||
/// rmc::assume(i > 10); | ||
/// ``` | ||
#[inline(never)] | ||
#[rustc_diagnostic_item = "RmcAssume"] | ||
pub fn assume(_cond: bool) {} | ||
|
||
/// This creates an unconstrained value of type `T`. You can assign the return value of this | ||
/// function to a variable that you want to make symbolic. | ||
/// | ||
/// # Example: | ||
/// | ||
/// In the snippet below, we are verifying the behavior of the function `fn_under_verification` | ||
/// under all possible i32 input values. | ||
/// | ||
/// ```rust | ||
/// let inputA = rmc::nondet::<i32>(); | ||
/// fn_under_verification(inputA); | ||
/// ``` | ||
#[inline(never)] | ||
#[rustc_diagnostic_item = "RmcNonDet"] | ||
pub fn nondet<T>() -> T { | ||
unimplemented!("RMC nondet") | ||
} | ||
|
||
/// Function used in tests for cases where the condition is not always true. | ||
#[inline(never)] | ||
#[rustc_diagnostic_item = "RmcExpectFail"] | ||
pub fn expect_fail(_cond: bool, _message: &str) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
SCRIPTS_DIR="$(dirname $SCRIPT_DIR)" | ||
REPO_DIR="$(dirname $SCRIPTS_DIR)" | ||
|
||
export RUSTC=$(${SCRIPTS_DIR}/rmc-rustc --rmc-path) | ||
cargo build --manifest-path "${REPO_DIR}/library/rmc/Cargo.toml" $@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.