diff --git a/src/opaque.rs b/src/opaque.rs index e0f8ce2c2..2ca90af43 100644 --- a/src/opaque.rs +++ b/src/opaque.rs @@ -1,6 +1,7 @@ #![allow(missing_docs)] use crate::void; +use core::cell::UnsafeCell; use core::marker::{PhantomData, PhantomPinned}; use core::mem; @@ -14,7 +15,14 @@ use core::mem; pub struct Opaque { _private: [*const void; 0], _pinned: PhantomData, + _mutable: SyncUnsafeCell>, } +// TODO: https://github.com/rust-lang/rust/issues/95439 +#[repr(transparent)] +struct SyncUnsafeCell(UnsafeCell); + +unsafe impl Sync for SyncUnsafeCell {} + const_assert_eq!(0, mem::size_of::()); const_assert_eq!(1, mem::align_of::());