1 // check-fail
2 //
3 // regression test for issue 52893
4 trait At<Name> {
5 type AtRes;
at(self) -> Self::AtRes6 fn at(self) -> Self::AtRes;
7 }
8
9 trait Push<T> {
10 type PushRes;
push(self, other: T) -> Self::PushRes11 fn push(self, other: T) -> Self::PushRes;
12 }
13
14 trait AddClass<Name, F> {
15 type AddRes;
init(self, func: F)16 fn init(self, func: F);
17 }
18
19 trait ToRef {
20 type RefRes;
to_ref(&self) -> Self::RefRes21 fn to_ref(&self) -> Self::RefRes;
22 }
23
24 struct Class<P>(P);
25
26 impl<P> Class<P> {
with<Name, F>(self) -> <Self as AddClass<Name, F>>::AddRes where Self: AddClass<Name, F>,27 fn with<Name, F>(self) -> <Self as AddClass<Name, F>>::AddRes
28 where
29 Self: AddClass<Name, F>,
30 {
31 todo!()
32 }
33
from<F>(self) -> <Self as AddClass<P, F>>::AddRes where Self: AddClass<P, F>,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
init(self, func: F)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
main()57 fn main() {}
58