Ensure opaque types are !Unpin
diff --git a/src/cxx_string.rs b/src/cxx_string.rs
index 5010175..7ee8987 100644
--- a/src/cxx_string.rs
+++ b/src/cxx_string.rs
@@ -1,6 +1,7 @@
use alloc::borrow::Cow;
use alloc::string::String;
use core::fmt::{self, Debug, Display};
+use core::marker::{PhantomData, PhantomPinned};
use core::slice;
use core::str::{self, Utf8Error};
@@ -26,6 +27,7 @@
#[repr(C)]
pub struct CxxString {
_private: [u8; 0],
+ _pinned: PhantomData<PhantomPinned>,
}
impl CxxString {
diff --git a/src/cxx_vector.rs b/src/cxx_vector.rs
index 5fb0807..d25ea91 100644
--- a/src/cxx_vector.rs
+++ b/src/cxx_vector.rs
@@ -1,7 +1,7 @@
use crate::cxx_string::CxxString;
use core::ffi::c_void;
use core::fmt::{self, Display};
-use core::marker::PhantomData;
+use core::marker::{PhantomData, PhantomPinned};
use core::mem;
use core::ptr;
use core::slice;
@@ -17,6 +17,7 @@
#[repr(C, packed)]
pub struct CxxVector<T> {
_private: [T; 0],
+ _pinned: PhantomData<PhantomPinned>,
}
impl<T> CxxVector<T>
diff --git a/src/opaque.rs b/src/opaque.rs
index bad57e7..3c8f536 100644
--- a/src/opaque.rs
+++ b/src/opaque.rs
@@ -1,3 +1,4 @@
+use core::marker::{PhantomData, PhantomPinned};
use core::mem;
// . size = 0
@@ -5,9 +6,11 @@
// . ffi-safe
// . !Send
// . !Sync
+// . !Unpin
#[repr(C, packed)]
pub struct Opaque {
_private: [*const u8; 0],
+ _pinned: PhantomData<PhantomPinned>,
}
const_assert_eq!(0, mem::size_of::<Opaque>());