1 // Test that the unboxed closure sugar can be used with an arbitrary
2 // struct type and that it is equivalent to the same syntax using
3 // angle brackets. This test covers only simple types and in
4 // particular doesn't test bound regions.
6 #![feature(unboxed_closures)]
11 fn dummy(&self, t: T, u: Self::Output);
14 trait Eq<X: ?Sized> { }
15 impl<X: ?Sized> Eq<X> for X { }
16 fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
19 // No errors expected:
20 eq::< dyn Foo<(),Output=()>, dyn Foo() >();
21 eq::< dyn Foo<(isize,),Output=()>, dyn Foo(isize) >();
22 eq::< dyn Foo<(isize,usize),Output=()>, dyn Foo(isize,usize) >();
23 eq::< dyn Foo<(isize,usize),Output=usize>, dyn Foo(isize,usize) -> usize >();
24 eq::< dyn Foo<(&'a isize,&'b usize),Output=usize>, dyn Foo(&'a isize,&'b usize) -> usize >();
26 // Test that anonymous regions in `()` form are equivalent
27 // to fresh bound regions, and that we can intermingle
28 // named and anonymous as we choose:
29 eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
30 dyn for<'x,'y> Foo(&'x isize,&'y usize) -> usize >();
31 eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
32 dyn for<'x> Foo(&'x isize,&usize) -> usize >();
33 eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
34 dyn for<'y> Foo(&isize,&'y usize) -> usize >();
35 eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
36 dyn Foo(&isize,&usize) -> usize >();
39 eq::< dyn for<'x> Foo<(&'x isize,), Output=&'x isize>,
40 dyn Foo(&isize) -> &isize >();
43 eq::< dyn Foo<(),Output=()>,