]> git.proxmox.com Git - rustc.git/blob - src/test/ui/traits/issue-52893.rs
New upstream version 1.57.0+dfsg1
[rustc.git] / src / test / ui / traits / issue-52893.rs
1 // check-fail
2 //
3 // regression test for issue 52893
4 trait At<Name> {
5 type AtRes;
6 fn at(self) -> Self::AtRes;
7 }
8
9 trait Push<T> {
10 type PushRes;
11 fn push(self, other: T) -> Self::PushRes;
12 }
13
14 trait AddClass<Name, F> {
15 type AddRes;
16 fn init(self, func: F);
17 }
18
19 trait ToRef {
20 type RefRes;
21 fn to_ref(&self) -> Self::RefRes;
22 }
23
24 struct Class<P>(P);
25
26 impl<P> Class<P> {
27 fn with<Name, F>(self) -> <Self as AddClass<Name, F>>::AddRes
28 where
29 Self: AddClass<Name, F>,
30 {
31 todo!()
32 }
33
34 fn from<F>(self) -> <Self as AddClass<P, F>>::AddRes
35 where
36 Self: AddClass<P, F>,
37 {
38 todo!()
39 }
40 }
41
42 impl<F, Name, P> AddClass<Name, F> for Class<P>
43 where
44 Self: At<Name>,
45 <Self as At<Name>>::AtRes: Push<F>,
46 <<Self as At<Name>>::AtRes as Push<F>>::PushRes: ToRef<RefRes = Self> + Push<F>,
47 {
48 type AddRes = ();
49
50 fn init(self, func: F) {
51 let builder = self.at().push(func);
52 let output = builder.to_ref();
53 builder.push(output); //~ ERROR mismatched types [E0308]
54 }
55 }
56
57 fn main() {}