Skip to content

Commit

Permalink
Merge pull request #1370 from dtolnay/unsafecell
Browse files Browse the repository at this point in the history
Drop "readonly" LLVM attribute from references to opaque C++ types
  • Loading branch information
dtolnay authored Aug 30, 2024
2 parents 4287520 + 642278c commit 54233f7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/opaque.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(missing_docs)]

use crate::void;
use core::cell::UnsafeCell;
use core::marker::{PhantomData, PhantomPinned};
use core::mem;

Expand All @@ -14,7 +15,14 @@ use core::mem;
pub struct Opaque {
_private: [*const void; 0],
_pinned: PhantomData<PhantomPinned>,
_mutable: SyncUnsafeCell<PhantomData<()>>,
}

// TODO: https://github.com/rust-lang/rust/issues/95439
#[repr(transparent)]
struct SyncUnsafeCell<T>(UnsafeCell<T>);

unsafe impl<T> Sync for SyncUnsafeCell<T> {}

const_assert_eq!(0, mem::size_of::<Opaque>());
const_assert_eq!(1, mem::align_of::<Opaque>());

0 comments on commit 54233f7

Please sign in to comment.