Skip to content

Feat: add tag-std and cargo-tag-std demo by driving rustc #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 9, 2025

Conversation

zjp-CN
Copy link
Member

@zjp-CN zjp-CN commented May 8, 2025

********* "demo" [Rlib] has reached 10 instances *********
(stable mir) "test" ("src/lib.rs:8:1: 8:21") => "#[tag_std::unreachable]\n"

(stable mir) "MyStruct::get" ("src/lib.rs:27:5: 27:42") => "#[tag_std::contract(!Null(self.ptr) && Align(self.ptr, u8) &&\nAllocated(self.ptr, u8, self.len, *) && Init(self.ptr, u8, self.len, *) &&\nValidInt(self.len*sizeof(u8), [0,isize::MAX]) && Alias(self.ptr, *))]\n"

********* "demo" [Executable] has reached 18 instances *********
(internal api) "demo::MyStruct::get" ("/home/zjp/rust/tag-std/demo/rustc_driver/tests/basic/src/lib.rs:27:5: 27:42") => "#[tag_std::contract(!Null(self.ptr) && Align(self.ptr, u8) &&\nAllocated(self.ptr, u8, self.len, *) && Init(self.ptr, u8, self.len, *) &&\nValidInt(self.len*sizeof(u8), [0,isize::MAX]) && Alias(self.ptr, *))]\n"

image

zjp-CN added 4 commits May 8, 2025 17:26
+ tag_std=/home/zjp/rust/tag-std/demo/rustc_driver/target/debug/tag-std
+ cd ./tests/basic
+ /home/zjp/rust/tag-std/demo/rustc_driver/target/debug/tag-std src/lib.rs --crate-type=lib
["test"] "#[tag_std::unreachable]\n"

["MyStruct::get"] "#[tag_std::contract(!Null(self.ptr) && Align(self.ptr, u8) &&\nAllocated(self.ptr, u8, self.len, *) && Init(sel
f.ptr, u8, self.len, *) &&\nValidInt(self.len*sizeof(u8), [0,isize::MAX]) && Alias(self.ptr, *))]\n"
rustc_driver/tests/basic $ tag-std src/main.rs --extern demo -L target/debug/
(body) "main"
(body) "std::vec::Vec::<u8>::new"
(body) "std::vec::Vec::<u8>::into_raw_parts"
(body) "core::fmt::rt::Argument::<'_>::new_debug::<&mut [u8]>"
(body) "<&mut [u8] as std::fmt::Debug>::fmt"
(body) "<[u8] as std::fmt::Debug>::fmt"
(body) "std::fmt::DebugList::<'_, '_>::entries::<&u8, std::slice::Iter<'_, u8>>"
(body) "<std::slice::Iter<'_, u8> as std::iter::IntoIterator>::into_iter"
(body) "<std::slice::Iter<'_, u8> as std::iter::Iterator>::next"
(body) "core::num::<impl usize>::unchecked_sub::precondition_check"
(body) "core::fmt::rt::<impl std::fmt::Arguments<'_>>::new_v1::<2, 1>"
[src/main.rs:47:5] reachability.instances.len() = 18
[src/main.rs:47:5] reachability.cross_crates = false
(error) demo::MyStruct::from not converted to be an item: Error("Item kind `Item` cannot be converted")
(error) core::panicking::panic_nounwind not converted to be an item: Error("Item kind `Item` cannot be converted")
(error) std::io::_print not converted to be an item: Error("Item kind `Item` cannot be converted")
(error) std::fmt::DebugList::<'_, '_>::finish not converted to be an item: Error("Item kind `Item` cannot be converted")
(error) demo::MyStruct::get not converted to be an item: Error("Item kind `Item` cannot be converted")
(error) std::fmt::DebugList::<'_, '_>::entry not converted to be an item: Error("Item kind `Item` cannot be converted")
(error) std::fmt::Formatter::<'_>::debug_list not converted to be an item: Error("Item kind `Item` cannot be converted")
…port

+ /home/zjp/rust/tag-std/demo/rustc_driver/target/debug/cargo_tag_std
   Compiling demo v0.1.0 (/home/zjp/rust/tag-std/demo/rustc_driver/tests/basic)
[src/main.rs:53:5] reachability.instances.len() = 10

(stable mir) "test" ("src/lib.rs:8:1: 8:21") => "#[tag_std::unreachable]\n"

(stable mir) "MyStruct::get" ("src/lib.rs:27:5: 27:42") => "#[tag_std::contract(!Null(self.ptr) && Align(self.ptr, u8) &&\nAllocated(self.ptr,
 u8, self.len, *) && Init(self.ptr, u8, self.len, *) &&\nValidInt(self.len*sizeof(u8), [0,isize::MAX]) && Alias(self.ptr, *))]\n"
[src/main.rs:53:5] reachability.instances.len() = 18

(internal api) "demo::MyStruct::get" ("/home/zjp/rust/tag-std/demo/rustc_driver/tests/basic/src/lib.rs:27:5: 27:42") => "#[tag_std::contract(!
Null(self.ptr) && Align(self.ptr, u8) &&\nAllocated(self.ptr, u8, self.len, *) && Init(self.ptr, u8, self.len, *) &&\nValidInt(self.len*sizeof
(u8), [0,isize::MAX]) && Alias(self.ptr, *))]\n"
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.75s
@zjp-CN zjp-CN force-pushed the rustc_driver branch 3 times, most recently from 18deb0f to f8e51a7 Compare May 8, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants