]> git.lizzy.rs Git - rust.git/blob - src/test/ui/kindck/kindck-send-object1.rs
Compress amount of hashed bytes for `isize` values in StableHasher
[rust.git] / src / test / ui / kindck / kindck-send-object1.rs
1 // Test which object types are considered sendable. This test
2 // is broken into two parts because some errors occur in distinct
3 // phases in the compiler. See kindck-send-object2.rs as well!
4
5 fn assert_send<T:Send+'static>() { }
6 trait Dummy { }
7
8 // careful with object types, who knows what they close over...
9 fn test51<'a>() {
10     assert_send::<&'a dyn Dummy>();
11     //~^ ERROR `(dyn Dummy + 'a)` cannot be shared between threads safely [E0277]
12 }
13 fn test52<'a>() {
14     assert_send::<&'a (dyn Dummy + Sync)>();
15     //~^ ERROR does not fulfill the required lifetime
16 }
17
18 // ...unless they are properly bounded
19 fn test60() {
20     assert_send::<&'static (dyn Dummy + Sync)>();
21 }
22 fn test61() {
23     assert_send::<Box<dyn Dummy + Send>>();
24 }
25
26 // closure and object types can have lifetime bounds which make
27 // them not ok
28 fn test_71<'a>() {
29     assert_send::<Box<dyn Dummy + 'a>>();
30     //~^ ERROR `(dyn Dummy + 'a)` cannot be sent between threads safely
31 }
32
33 fn main() { }