Skip to content

Commit 16c34dd

Browse files
committed
Add SpecPartialEqOp for raw_ptr
fix
1 parent 938ee15 commit 16c34dd

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

source/rust_verify_test/tests/raw_ptrs.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ test_verify_one_file! {
222222

223223
test_verify_one_file! {
224224
#[test] pointer_exec_eq_is_not_spec_eq verus_code! {
225+
use vstd::prelude::*;
225226
fn test_const_eq(x: *const u8, y: *const u8) {
226227
if x == y {
228+
assert(x@.addr == y@.addr);
227229
assert(x == y); // FAILS
228230
}
229231
}
@@ -233,7 +235,7 @@ test_verify_one_file! {
233235
assert(x == y); // FAILS
234236
}
235237
}
236-
} => Err(err) => assert_vir_error_msg(err, "The verifier does not yet support the following Rust feature: ==/!= for non smt equality types")
238+
} => Err(err) => assert_fails(err, 2)
237239
}
238240

239241
test_verify_one_file! {

source/vstd/raw_ptr.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ impl<T: ?Sized> View for *mut T {
144144
spec fn view(&self) -> Self::V;
145145
}
146146

147+
#[cfg(verus_keep_ghost)]
148+
impl<T: ?Sized> super::std_specs::cmp::SpecPartialEqOp<*mut T> for *mut T {
149+
open spec fn spec_partial_eq(&self, other: &*mut T) -> bool {
150+
self@.addr == other@.addr
151+
}
152+
}
153+
147154
impl<T: ?Sized> View for *const T {
148155
type V = PtrData;
149156

@@ -153,6 +160,13 @@ impl<T: ?Sized> View for *const T {
153160
}
154161
}
155162

163+
#[cfg(verus_keep_ghost)]
164+
impl<T: ?Sized> super::std_specs::cmp::SpecPartialEqOp<*const T> for *const T {
165+
open spec fn spec_partial_eq(&self, other: &*const T) -> bool {
166+
self@.addr == other@.addr
167+
}
168+
}
169+
156170
impl<T> View for PointsTo<T> {
157171
type V = PointsToData<T>;
158172

0 commit comments

Comments
 (0)