]>
Commit | Line | Data |
---|---|---|
94222f64 XL |
1 | trait ATC<'a> { |
2 | type Type: Sized; | |
3 | } | |
4 | ||
5 | trait WithDefault: for<'a> ATC<'a> { | |
6 | fn with_default<F: for<'a> Fn(<Self as ATC<'a>>::Type)>(f: F); | |
7 | } | |
8 | ||
9 | fn call<'b, T: for<'a> ATC<'a>, F: for<'a> Fn(<T as ATC<'a>>::Type)>( | |
10 | f: F, | |
11 | x: <T as ATC<'b>>::Type, | |
12 | ) { | |
13 | f(x); | |
14 | } | |
15 | ||
16 | impl<'a> ATC<'a> for () { | |
17 | type Type = Self; | |
18 | } | |
19 | ||
20 | impl WithDefault for () { | |
21 | fn with_default<F: for<'a> Fn(<Self as ATC<'a>>::Type)>(f: F) { | |
22 | // Errors with a bogus type mismatch. | |
23 | //f(()); | |
24 | // Going through another generic function works fine. | |
25 | call(f, ()); | |
26 | //~^ expected a | |
27 | } | |
28 | } | |
29 | ||
30 | fn main() { | |
31 | // <()>::with_default(|_| {}); | |
32 | } |