Skip to content

Commit

Permalink
Hide the UnsafeCell content of opaque C++ types in regard to unwind s…
Browse files Browse the repository at this point in the history
…afety
  • Loading branch information
dtolnay committed Aug 30, 2024
1 parent 82888f1 commit d4f3c16
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::void;
use core::cell::UnsafeCell;
use core::marker::{PhantomData, PhantomPinned};
use core::mem;
use core::panic::RefUnwindSafe;

// . size = 0
// . align = 1
Expand All @@ -19,6 +20,8 @@ pub struct Opaque {
_mutable: SyncUnsafeCell<PhantomData<()>>,
}

impl RefUnwindSafe for Opaque {}

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

0 comments on commit d4f3c16

Please sign in to comment.