mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-27 01:11:38 +00:00
Tweak opaque type repr for slightly more evocative errors
This commit is contained in:
parent
9f0e67d98f
commit
248994aa51
@ -486,3 +486,6 @@ chars! {
|
||||
a b c d e f g h i j k l m n o p q r s t u v w x y z
|
||||
__ // underscore
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
struct void(core::ffi::c_void);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use crate::void;
|
||||
use core::marker::{PhantomData, PhantomPinned};
|
||||
use core::mem;
|
||||
|
||||
@ -11,7 +12,7 @@ use core::mem;
|
||||
// . !Unpin
|
||||
#[repr(C, packed)]
|
||||
pub struct Opaque {
|
||||
_private: [*const u8; 0],
|
||||
_private: [*const void; 0],
|
||||
_pinned: PhantomData<PhantomPinned>,
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
error[E0277]: `*const u8` cannot be sent between threads safely
|
||||
error[E0277]: `*const cxx::void` cannot be sent between threads safely
|
||||
--> $DIR/opaque_autotraits.rs:13:5
|
||||
|
|
||||
8 | fn assert_send<T: Send>() {}
|
||||
| ---- required by this bound in `assert_send`
|
||||
...
|
||||
13 | assert_send::<ffi::Opaque>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const u8` cannot be sent between threads safely
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const cxx::void` cannot be sent between threads safely
|
||||
|
|
||||
= help: within `ffi::Opaque`, the trait `Send` is not implemented for `*const u8`
|
||||
= note: required because it appears within the type `[*const u8; 0]`
|
||||
= help: within `ffi::Opaque`, the trait `Send` is not implemented for `*const cxx::void`
|
||||
= note: required because it appears within the type `[*const cxx::void; 0]`
|
||||
= note: required because it appears within the type `cxx::private::Opaque`
|
||||
note: required because it appears within the type `ffi::Opaque`
|
||||
--> $DIR/opaque_autotraits.rs:4:14
|
||||
@ -16,17 +16,17 @@ note: required because it appears within the type `ffi::Opaque`
|
||||
4 | type Opaque;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0277]: `*const u8` cannot be shared between threads safely
|
||||
error[E0277]: `*const cxx::void` cannot be shared between threads safely
|
||||
--> $DIR/opaque_autotraits.rs:14:5
|
||||
|
|
||||
9 | fn assert_sync<T: Sync>() {}
|
||||
| ---- required by this bound in `assert_sync`
|
||||
...
|
||||
14 | assert_sync::<ffi::Opaque>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const u8` cannot be shared between threads safely
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const cxx::void` cannot be shared between threads safely
|
||||
|
|
||||
= help: within `ffi::Opaque`, the trait `Sync` is not implemented for `*const u8`
|
||||
= note: required because it appears within the type `[*const u8; 0]`
|
||||
= help: within `ffi::Opaque`, the trait `Sync` is not implemented for `*const cxx::void`
|
||||
= note: required because it appears within the type `[*const cxx::void; 0]`
|
||||
= note: required because it appears within the type `cxx::private::Opaque`
|
||||
note: required because it appears within the type `ffi::Opaque`
|
||||
--> $DIR/opaque_autotraits.rs:4:14
|
||||
|
Loading…
Reference in New Issue
Block a user