Skip to content

Commit 2ca4ee7

Browse files
committed
Fix harnesses
1 parent c2b65cf commit 2ca4ee7

File tree

1 file changed

+28
-12
lines changed
  • library/alloc/src/collections/binary_heap

1 file changed

+28
-12
lines changed

library/alloc/src/collections/binary_heap/mod.rs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,30 +1913,46 @@ mod verify {
19131913
use super::*;
19141914

19151915
// unsafe fn sift_up(&mut self, start: usize, pos: usize) -> usize
1916-
#[kani::proof_for_contract(impl<T::sift_up)]
1916+
#[kani::proof_for_contract(BinaryHeap<T, A>::sift_up)]
19171917
pub fn check_sift_up() {
1918-
let obj : impl<T = kani::any();
1919-
let _ = obj.sift_up(kani::any(), kani::any());
1918+
// TODO: this isn't exactly an arbitrary heap
1919+
let mut heap = BinaryHeap::new_in(Global);
1920+
heap.push(kani::any::<usize>());
1921+
unsafe {
1922+
let _ = heap.sift_up(kani::any(), kani::any());
1923+
}
19201924
}
19211925

19221926
// unsafe fn sift_down_range(&mut self, pos: usize, end: usize)
1923-
#[kani::proof_for_contract(impl<T::sift_down_range)]
1927+
#[kani::proof_for_contract(BinaryHeap<T, A>::sift_down_range)]
19241928
pub fn check_sift_down_range() {
1925-
let obj : impl<T = kani::any();
1926-
let _ = obj.sift_down_range(kani::any(), kani::any());
1929+
// TODO: this isn't exactly an arbitrary heap
1930+
let mut heap = BinaryHeap::new_in(Global);
1931+
heap.push(kani::any::<usize>());
1932+
unsafe {
1933+
let _ = heap.sift_down_range(kani::any(), kani::any());
1934+
}
19271935
}
19281936

19291937
// unsafe fn sift_down(&mut self, pos: usize)
1930-
#[kani::proof_for_contract(impl<T::sift_down)]
1938+
#[kani::proof_for_contract(BinaryHeap<T, A>::sift_down)]
19311939
pub fn check_sift_down() {
1932-
let obj : impl<T = kani::any();
1933-
let _ = obj.sift_down(kani::any());
1940+
// TODO: this isn't exactly an arbitrary heap
1941+
let mut heap = BinaryHeap::new_in(Global);
1942+
heap.push(kani::any::<usize>());
1943+
unsafe {
1944+
let _ = heap.sift_down(kani::any());
1945+
}
19341946
}
19351947

19361948
// unsafe fn sift_down_to_bottom(&mut self, mut pos: usize)
1937-
#[kani::proof_for_contract(impl<T::sift_down_to_bottom)]
1949+
#[kani::proof_for_contract(BinaryHeap<T, A>::sift_down_to_bottom)]
19381950
pub fn check_sift_down_to_bottom() {
1939-
let obj : impl<T = kani::any();
1940-
let _ = obj.sift_down_to_bottom(kani::any());
1951+
// TODO: this isn't exactly an arbitrary heap
1952+
let mut heap = BinaryHeap::new_in(Global);
1953+
heap.push(kani::any::<usize>());
1954+
unsafe {
1955+
let _ = heap.sift_down_to_bottom(kani::any());
1956+
}
19411957
}
19421958
}

0 commit comments

Comments
 (0)