Skip to content

Commit 4c6fc31

Browse files
committed
Ignore Gc::ptr_eq
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 752398b commit 4c6fc31

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

gc/src/gc.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::trace::{Finalize, Trace};
22
use std::cell::{Cell, RefCell};
33
use std::mem;
4-
use std::ptr::NonNull;
4+
use std::ptr::{self, NonNull};
55

66
const INITIAL_THRESHOLD: usize = 100;
77

@@ -119,6 +119,13 @@ impl<T: Trace> GcBox<T> {
119119
}
120120

121121
impl<T: Trace + ?Sized> GcBox<T> {
122+
/// Returns `true` if the two references refer to the same `GcBox`.
123+
pub(crate) fn ptr_eq(this: &GcBox<T>, other: &GcBox<T>) -> bool {
124+
// Ignore vtables with .header to work around
125+
// https://github.com/rust-lang/rust/issues/46139
126+
ptr::eq(&this.header, &other.header)
127+
}
128+
122129
/// Marks this `GcBox` and marks through its data.
123130
pub(crate) unsafe fn trace_inner(&self) {
124131
let marked = self.header.marked.get();

gc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<T: Trace> Gc<T> {
9090
impl<T: Trace + ?Sized> Gc<T> {
9191
/// Returns `true` if the two `Gc`s point to the same allocation.
9292
pub fn ptr_eq(this: &Gc<T>, other: &Gc<T>) -> bool {
93-
ptr::eq(this.inner(), other.inner())
93+
GcBox::ptr_eq(this.inner(), other.inner())
9494
}
9595
}
9696

0 commit comments

Comments
 (0)