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.
Squashed 'library/' changes from a2cf63619d7..3e6b1c26cd5
3e6b1c26cd5 Merge commit 'cee9f0879743983a0924f94d37e0abd6d464bb4f' into sync-2024-07-20 496b81c004b Merge commit 'dd0d2657eb2c8466bbd9fa6ea4bf2b094565c680' into sync-2024-07-17 e3a5cb88602 Merge commit 'dd0d2657eb2c8466bbd9fa6ea4bf2b094565c680' into sync-2024-07-17 2f83451ef02 Reapply repository changes to library files 7b3d8ba5d15 Reapply repository changes to library files c0a2240a2e7 Move contracts back to library/contracts 9d2c65282fd Move contracts back to library/contracts 586d10f1860 Merge commit '0cd155fda0d5b0b3ba666cd9df978d380f6c7067' as 'library' 9cab9f2bf44 Merge commit '0cd155fda0d5b0b3ba666cd9df978d380f6c7067' as 'library' 47a29de Delete library folder so we can recreate subtree eea60ef Record library patch and delete library/ af85a10 Move contracts out of library for now fd1c9c2 Add contracts for Layout and Alignment (#33) 5d8ee62 Add permissions needed to modify PR (#34) bbfbb19 Add PR approval check for specific directories (#31) 5f2798e Add a challenge for `linked_list` (#30) 5a7327e Propose a new challenge about pointer arithmetic ops (#23) c7dd281 Add committee application guideline and committee TOML file (#32) df109da Add tracking issue for challenges template (#27) 52bea58 Remove copyright strings (#24) e15993a Fix challenge numbers and move to challenges/ dir (#22) ebb5c7f Add copyright file (#13) df8da5a Add a few more contract and harness examples (#18) 5b70960 Run CI checks on all PRs against to main (#20) a7c6d00 refined core transmutation challenge. (#11) 614eb77 Add simple ensures, requires, safety predicates (#15) 3a164b0 Add Challenge 2: Verify the memory safery of core intrinsics using raw pointers (#14) 8931064 Add Kani usage and verify-std section to verification book (#12) 5a369ec Add initial challenge template (#10) b8464d4 Add Rust tests and Kani workflow (#9) 6f793b3 Update text and book ec8c25c Fix text 4a6eb06 Add disclaimer, and fix links (#5) dc3222b Fix the book script (#8) c9653b7 Add copyright check file (#7) 05dca8f Add contest book (#6) 838f888 Adding std library as a subtree 6efb19b Merge commit '2faab3154fb126423ccf8e56c10577a3cd3f9457' as 'library' 2faab31 Squashed 'library/' content from commit f461edda8cb 104c14e Update README.md (#3) 7c30a94 Add README.md file (#2) f24a233 Create initial commit with the license files git-subtree-dir: library git-subtree-split: 3e6b1c26cd58a676a339261c5e190fa29b903833
- Loading branch information
Showing
13 changed files
with
267 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "safety" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[dependencies] | ||
proc-macro2 = "1.0" | ||
proc-macro-error = "1.0.4" | ||
quote = "1.0.20" | ||
syn = { version = "2.0.18", features = ["full"] } |
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,4 @@ | ||
fn main() { | ||
// We add the configurations here to be checked. | ||
println!("cargo:rustc-check-cfg=cfg(kani_host)"); | ||
} |
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,21 @@ | ||
use proc_macro::{TokenStream}; | ||
use quote::{quote, format_ident}; | ||
use syn::{ItemFn, parse_macro_input}; | ||
|
||
pub(crate) fn requires(attr: TokenStream, item: TokenStream) -> TokenStream { | ||
rewrite_attr(attr, item, "requires") | ||
} | ||
|
||
pub(crate) fn ensures(attr: TokenStream, item: TokenStream) -> TokenStream { | ||
rewrite_attr(attr, item, "ensures") | ||
} | ||
|
||
fn rewrite_attr(attr: TokenStream, item: TokenStream, name: &str) -> TokenStream { | ||
let args = proc_macro2::TokenStream::from(attr); | ||
let fn_item = parse_macro_input!(item as ItemFn); | ||
let attribute = format_ident!("{}", name); | ||
quote!( | ||
#[kani_core::#attribute(#args)] | ||
#fn_item | ||
).into() | ||
} |
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,25 @@ | ||
//! Implement a few placeholders for contract attributes until they get implemented upstream. | ||
//! Each tool should implement their own version in a separate module of this crate. | ||
|
||
use proc_macro::TokenStream; | ||
use proc_macro_error::proc_macro_error; | ||
|
||
#[cfg(kani_host)] | ||
#[path = "kani.rs"] | ||
mod tool; | ||
|
||
#[cfg(not(kani_host))] | ||
#[path = "runtime.rs"] | ||
mod tool; | ||
|
||
#[proc_macro_error] | ||
#[proc_macro_attribute] | ||
pub fn requires(attr: TokenStream, item: TokenStream) -> TokenStream { | ||
tool::requires(attr, item) | ||
} | ||
|
||
#[proc_macro_error] | ||
#[proc_macro_attribute] | ||
pub fn ensures(attr: TokenStream, item: TokenStream) -> TokenStream { | ||
tool::ensures(attr, item) | ||
} |
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,15 @@ | ||
use proc_macro::TokenStream; | ||
|
||
/// For now, runtime requires is a no-op. | ||
/// | ||
/// TODO: At runtime the `requires` should become an assert unsafe precondition. | ||
pub(crate) fn requires(_attr: TokenStream, item: TokenStream) -> TokenStream { | ||
item | ||
} | ||
|
||
/// For now, runtime requires is a no-op. | ||
/// | ||
/// TODO: At runtime the `ensures` should become an assert as well. | ||
pub(crate) fn ensures(_attr: TokenStream, item: TokenStream) -> TokenStream { | ||
item | ||
} |
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
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