]>
Commit | Line | Data |
---|---|---|
e1599b0c | 1 | // check-pass |
dc9dc135 XL |
2 | |
3 | // This test checks that trait objects involving trait aliases are well-formed. | |
4 | ||
5 | #![feature(trait_alias)] | |
6 | ||
7 | trait Obj {} | |
8 | ||
9 | trait _0 = Send + Sync; | |
10 | ||
11 | // Just auto traits: | |
12 | ||
13 | trait _1 = _0 + Send + Sync; | |
14 | ||
15 | use std::marker::Unpin; | |
16 | ||
17 | fn _f0() { | |
18 | let _: Box<dyn _0>; | |
19 | let _: Box<dyn _1>; | |
20 | let _: Box<dyn Unpin + _1 + Send + Sync>; | |
21 | } | |
22 | ||
23 | // Include object safe traits: | |
24 | ||
25 | fn _f1() { | |
26 | let _: Box<dyn Obj + _0>; | |
27 | let _: Box<dyn Obj + _1>; | |
28 | let _: Box<dyn Obj + _1 + _0>; | |
29 | } | |
30 | ||
31 | // And when the object safe trait is in a trait alias: | |
32 | ||
33 | trait _2 = Obj; | |
34 | ||
35 | fn _f2() { | |
36 | let _: Box<dyn _2 + _0>; | |
37 | let _: Box<dyn _2 + _1>; | |
38 | let _: Box<dyn _2 + _1 + _0>; | |
39 | } | |
40 | ||
41 | // And it should also work when that trait is has auto traits to the right of it. | |
42 | ||
43 | trait _3 = Obj + Unpin; | |
44 | ||
45 | fn _f3() { | |
46 | let _: Box<dyn _3 + _0>; | |
47 | let _: Box<dyn _3 + _1>; | |
48 | let _: Box<dyn _3 + _1 + _0>; | |
49 | } | |
50 | ||
51 | // Nest the trait deeply: | |
52 | ||
53 | trait _4 = _3; | |
54 | trait _5 = _4 + Sync + _0 + Send; | |
55 | trait _6 = _5 + Send + _1 + Sync; | |
56 | ||
57 | fn _f4() { | |
58 | let _: Box<dyn _6 + _0>; | |
59 | let _: Box<dyn _6 + _1>; | |
60 | let _: Box<dyn _6 + _1 + _0>; | |
61 | } | |
62 | ||
63 | // Just nest the trait alone: | |
64 | ||
65 | trait _7 = _2; | |
66 | trait _8 = _7; | |
67 | trait _9 = _8; | |
68 | ||
69 | fn _f5() { | |
70 | let _: Box<dyn _9>; | |
71 | } | |
72 | ||
73 | // First bound is auto trait: | |
74 | ||
75 | trait _10 = Send + Obj; | |
76 | trait _11 = Obj + Send; | |
77 | trait _12 = Sync + _11; | |
78 | trait _13 = Send + _12; | |
79 | ||
80 | fn f6() { | |
81 | let _: Box<dyn _10>; | |
82 | let _: Box<dyn _13>; | |
83 | } | |
84 | ||
85 | fn main() {} |