Skip to content

Commit 76128d3

Browse files
authored
Merge pull request #29 from rib/re-add-use-of-arc-ptr-eq
Revert recent change to avoid using Arc:ptr_eq
2 parents 77a5d23 + 86dd933 commit 76128d3

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

src/verifier.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,15 @@ struct VerifierClosure {
5757
impl Eq for VerifierClosure {}
5858
impl PartialEq for VerifierClosure {
5959
fn eq(&self, other: &Self) -> bool {
60-
// WARNING:
60+
// The libs team has resolved to update Arc::ptr_eq so that it doesn't compare
61+
// meta data for the wrapped value (such as a dyn trait vtable):
62+
// https://github.com/rust-lang/rust/issues/103763
6163
//
62-
// `Arc::ptr_eq(&self.func, &other.func)` is effectively implemented as:
63-
//
64-
// `Arc::as_ptr(&arc_a) == Arc::as_ptr(&arc_b)`
65-
//
66-
// which will notably result in comparing the vtable pointer for (wide) trait object pointers
67-
// and does _not_ match the API documentation that states:
68-
//
69-
// > Returns true if the two Arcs point to the same allocation (in a vein similar to ptr::eq).
70-
//
71-
// (which is what we need here)
72-
//
73-
// See: https://github.com/rust-lang/rust/pull/80505
74-
//
75-
// To ensure we are comparing the data pointer component of any wide pointer then we
76-
// additionally cast `Arc::as_ptr(&arc)` to a thin pointer to discard the vtable
77-
//
78-
// This avoid getting a `clippy::vtable_address_comparisons` error
79-
//
80-
// Ref: https://github.com/rust-lang/rust-clippy/issues/6524
81-
82-
let a = Arc::as_ptr(&self.func) as *const u8;
83-
let b = Arc::as_ptr(&other.func) as *const u8;
84-
std::ptr::eq(a, b)
64+
// In the meantime we can silence this clippy suggestion since the vtable is
65+
// benign in this case anyway:
66+
// https://github.com/rust-lang/rust-clippy/issues/6524
67+
#[allow(clippy::vtable_address_comparisons)]
68+
Arc::ptr_eq(&self.func, &other.func)
8569
}
8670
}
8771
impl std::fmt::Debug for VerifierClosure {

0 commit comments

Comments
 (0)