diff --git a/crossbeam-epoch/src/atomic.rs b/crossbeam-epoch/src/atomic.rs index f5e1c1611..b33a8ac86 100644 --- a/crossbeam-epoch/src/atomic.rs +++ b/crossbeam-epoch/src/atomic.rs @@ -891,8 +891,9 @@ impl From<*const T> for Atomic { } /// A trait for either `Owned` or `Shared` pointers. -// TODO: seal this trait https://github.com/crossbeam-rs/crossbeam/issues/620 -pub trait Pointer { +/// +/// This trait is sealed and cannot be implemented for types outside of `crossbeam-epoch`. +pub trait Pointer: crate::sealed::Sealed { /// Returns the machine representation of the pointer. fn into_ptr(self) -> *mut (); @@ -916,6 +917,7 @@ pub struct Owned { _marker: PhantomData>, } +impl crate::sealed::Sealed for Owned {} impl Pointer for Owned { #[inline] fn into_ptr(self) -> *mut () { @@ -1176,6 +1178,7 @@ impl Clone for Shared<'_, T> { impl Copy for Shared<'_, T> {} +impl crate::sealed::Sealed for Shared<'_, T> {} impl Pointer for Shared<'_, T> { #[inline] fn into_ptr(self) -> *mut () { diff --git a/crossbeam-epoch/src/lib.rs b/crossbeam-epoch/src/lib.rs index 80cc27305..16a1f437c 100644 --- a/crossbeam-epoch/src/lib.rs +++ b/crossbeam-epoch/src/lib.rs @@ -156,6 +156,10 @@ cfg_if! { }; pub use self::collector::{Collector, LocalHandle}; pub use self::guard::{unprotected, Guard}; + + mod sealed { + pub trait Sealed {} + } } }