]> git.lizzy.rs Git - rust.git/blob - tests/ui/kindck/kindck-send-object.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / ui / kindck / kindck-send-object.rs
1 // Test which of the builtin types are considered sendable. The tests
2 // in this file all test the "kind" violates detected during kindck.
3 // See all `regions-bounded-by-send.rs`
4
5 fn assert_send<T:Send>() { }
6 trait Dummy { }
7 trait Message : Send { }
8
9 // careful with object types, who knows what they close over...
10
11 fn object_ref_with_static_bound_not_ok() {
12     assert_send::<&'static (dyn Dummy + 'static)>();
13     //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277]
14 }
15
16 fn box_object_with_no_bound_not_ok<'a>() {
17     assert_send::<Box<dyn Dummy>>();
18     //~^ ERROR `dyn Dummy` cannot be sent between threads safely
19 }
20
21 fn object_with_send_bound_ok() {
22     assert_send::<&'static (dyn Dummy + Sync)>();
23     assert_send::<Box<dyn Dummy + Send>>();
24 }
25
26 fn main() { }