-
Notifications
You must be signed in to change notification settings - Fork 65
Challenge 4: Verify memory safety of BTreeMap node module #577
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1886,3 +1886,248 @@ fn move_to_slice<T>(src: &mut [MaybeUninit<T>], dst: &mut [MaybeUninit<T>]) { | |||||||||||||
|
|
||||||||||||||
| #[cfg(test)] | ||||||||||||||
| mod tests; | ||||||||||||||
|
|
||||||||||||||
| #[cfg(kani)] | ||||||||||||||
| #[unstable(feature = "kani", issue = "none")] | ||||||||||||||
| mod verify { | ||||||||||||||
| use core::kani; | ||||||||||||||
|
|
||||||||||||||
| use super::*; | ||||||||||||||
| use crate::alloc::Global; | ||||||||||||||
|
|
||||||||||||||
| /// Create a leaf node with n key-value pairs (keys 0..n, vals 10..10+n*10) | ||||||||||||||
| fn make_leaf(n: usize) -> NodeRef<marker::Owned, u32, u32, marker::Leaf> { | ||||||||||||||
| let mut node = NodeRef::new_leaf(Global); | ||||||||||||||
| for i in 0..n { | ||||||||||||||
| node.borrow_mut().push(i as u32, (i as u32 + 1) * 10); | ||||||||||||||
| } | ||||||||||||||
| node | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // === GROUP 1: BOUNDED FUNCTIONS === | ||||||||||||||
|
|
||||||||||||||
| // --- LeafNode::new --- | ||||||||||||||
| #[kani::proof] | ||||||||||||||
| fn verify_leaf_node_new() { | ||||||||||||||
|
Comment on lines
+1909
to
+1911
|
||||||||||||||
| // --- LeafNode::new --- | |
| #[kani::proof] | |
| fn verify_leaf_node_new() { | |
| // --- NodeRef::new_leaf --- | |
| #[kani::proof] | |
| fn verify_node_ref_new_leaf() { |
Copilot
AI
Mar 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle::into_val_mut returns a safe &mut V, so the unsafe { *val = 99; } block here is unnecessary. Dropping the unsafe reduces the apparent unsafe surface area and makes it clearer what the proof is actually exercising.
| unsafe { | |
| *val = 99; | |
| } | |
| *val = 99; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
make_leafhelper’s doc comment doesn’t match the values being inserted.(i + 1) * 10produces values10, 20, …, n*10(inclusive), not10..10+n*10as written; please update the comment to reflect the actual sequence to avoid confusion when interpreting proof expectations.