]> git.lizzy.rs Git - rust.git/blob - src/test/ui/kindck/kindck-send-object.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / kindck / kindck-send-object.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Test which of the builtin types are considered sendable. The tests
12 // in this file all test the "kind" violates detected during kindck.
13 // See all `regions-bounded-by-send.rs`
14
15 fn assert_send<T:Send>() { }
16 trait Dummy { }
17 trait Message : Send { }
18
19 // careful with object types, who knows what they close over...
20
21 fn object_ref_with_static_bound_not_ok() {
22     assert_send::<&'static (Dummy+'static)>();
23     //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277]
24 }
25
26 fn box_object_with_no_bound_not_ok<'a>() {
27     assert_send::<Box<Dummy>>();
28     //~^ ERROR `dyn Dummy` cannot be sent between threads safely
29 }
30
31 fn object_with_send_bound_ok() {
32     assert_send::<&'static (Dummy+Sync)>();
33     assert_send::<Box<Dummy+Send>>();
34 }
35
36 fn main() { }