Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the UnsafeCell content of opaque C++ types in regard to unwind safety #1372

Merged
merged 5 commits into from
Aug 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hide the UnsafeCell content of opaque C++ types in regard to unwind s…
…afety
  • Loading branch information
dtolnay committed Aug 30, 2024
commit d4f3c16c4a3a7a63067b24d08822227afd778627
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