From d4f3c16c4a3a7a63067b24d08822227afd778627 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 30 Aug 2024 14:52:46 -0700 Subject: [PATCH] Hide the UnsafeCell content of opaque C++ types in regard to unwind safety --- src/opaque.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/opaque.rs b/src/opaque.rs index bd4827858..8a495b329 100644 --- a/src/opaque.rs +++ b/src/opaque.rs @@ -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 @@ -19,6 +20,8 @@ pub struct Opaque { _mutable: SyncUnsafeCell>, } +impl RefUnwindSafe for Opaque {} + // TODO: https://github.com/rust-lang/rust/issues/95439 #[repr(transparent)] struct SyncUnsafeCell(UnsafeCell);