mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 23:29:50 +00:00
Merge pull request #858 from dtolnay/stdvectorautotrait
Add ui test of CxxVector autotrait impls
This commit is contained in:
commit
78c0c688b8
21
tests/ui/vector_autotraits.rs
Normal file
21
tests/ui/vector_autotraits.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use cxx::CxxVector;
|
||||
|
||||
#[cxx::bridge]
|
||||
mod ffi {
|
||||
extern "C++" {
|
||||
type ThreadSafe;
|
||||
type NotThreadSafe;
|
||||
}
|
||||
|
||||
impl CxxVector<ThreadSafe> {}
|
||||
impl CxxVector<NotThreadSafe> {}
|
||||
}
|
||||
|
||||
unsafe impl Send for ffi::ThreadSafe {}
|
||||
|
||||
fn assert_send<T: Send>() {}
|
||||
|
||||
fn main() {
|
||||
assert_send::<CxxVector<ffi::ThreadSafe>>();
|
||||
assert_send::<CxxVector<ffi::NotThreadSafe>>();
|
||||
}
|
19
tests/ui/vector_autotraits.stderr
Normal file
19
tests/ui/vector_autotraits.stderr
Normal file
@ -0,0 +1,19 @@
|
||||
error[E0277]: `*const cxx::void` cannot be sent between threads safely
|
||||
--> $DIR/vector_autotraits.rs:20:5
|
||||
|
|
||||
16 | fn assert_send<T: Send>() {}
|
||||
| ---- required by this bound in `assert_send`
|
||||
...
|
||||
20 | assert_send::<CxxVector<ffi::NotThreadSafe>>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const cxx::void` cannot be sent between threads safely
|
||||
|
|
||||
= help: within `CxxVector<NotThreadSafe>`, 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 `NotThreadSafe`
|
||||
--> $DIR/vector_autotraits.rs:7:14
|
||||
|
|
||||
7 | type NotThreadSafe;
|
||||
| ^^^^^^^^^^^^^
|
||||
= note: required because it appears within the type `[NotThreadSafe; 0]`
|
||||
= note: required because it appears within the type `CxxVector<NotThreadSafe>`
|
Loading…
Reference in New Issue
Block a user