• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // check-pass
2 
3 trait Variable<'a> {
4     type Type;
5 }
6 
7 impl Variable<'_> for () {
8     type Type = ();
9 }
10 
check<F, T>(_: F) where F: Fn(T), F: for<'a> Fn(<T as Variable<'a>>::Type), T: for<'a> Variable<'a>,11 fn check<F, T>(_: F)
12 where
13     F: Fn(T), // <- if removed, all fn_* then require type annotations
14     F: for<'a> Fn(<T as Variable<'a>>::Type),
15     T: for<'a> Variable<'a>,
16 {
17 }
18 
test(arg: impl Fn(()))19 fn test(arg: impl Fn(())) {
20     fn fn_1(_: ()) {}
21     let fn_2 = |_: ()| ();
22     let fn_3 = |a| fn_1(a);
23     let fn_4 = arg;
24 
25     check(fn_1); // Error
26     check(fn_2); // Ok
27     check(fn_3); // Ok
28     check(fn_4); // Error
29 }
30 
main()31 fn main() {}
32