]> git.proxmox.com Git - rustc.git/blame - src/test/ui/traits/alias/object-wf.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / ui / traits / alias / object-wf.rs
CommitLineData
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
7trait Obj {}
8
9trait _0 = Send + Sync;
10
11// Just auto traits:
12
13trait _1 = _0 + Send + Sync;
14
15use std::marker::Unpin;
16
17fn _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
25fn _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
33trait _2 = Obj;
34
35fn _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
43trait _3 = Obj + Unpin;
44
45fn _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
53trait _4 = _3;
54trait _5 = _4 + Sync + _0 + Send;
55trait _6 = _5 + Send + _1 + Sync;
56
57fn _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
65trait _7 = _2;
66trait _8 = _7;
67trait _9 = _8;
68
69fn _f5() {
70 let _: Box<dyn _9>;
71}
72
73// First bound is auto trait:
74
75trait _10 = Send + Obj;
76trait _11 = Obj + Send;
77trait _12 = Sync + _11;
78trait _13 = Send + _12;
79
80fn f6() {
81 let _: Box<dyn _10>;
82 let _: Box<dyn _13>;
83}
84
85fn main() {}