1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that the unboxed closure sugar can be used with an arbitrary
12 // struct type and that it is equivalent to the same syntax using
13 // angle brackets. This test covers only simple types and in
14 // particular doesn't test bound regions.
16 #![feature(unboxed_closures)]
20 fn dummy(&self, t: T, u: U);
23 trait Eq<Sized? X> for Sized? { }
24 impl<Sized? X> Eq<X> for X { }
25 fn eq<Sized? A,Sized? B:Eq<A>>() { }
28 // No errors expected:
29 eq::< Foo<(),()>, Foo() >();
30 eq::< Foo<(int,),()>, Foo(int) >();
31 eq::< Foo<(int,uint),()>, Foo(int,uint) >();
32 eq::< Foo<(int,uint),uint>, Foo(int,uint) -> uint >();
33 eq::< Foo<(&'a int,&'b uint),uint>, Foo(&'a int,&'b uint) -> uint >();
35 // Test that anonymous regions in `()` form are equivalent
36 // to fresh bound regions, and that we can intermingle
37 // named and anonymous as we choose:
38 eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>,
39 for<'a,'b> Foo(&'a int,&'b uint) -> uint >();
40 eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>,
41 for<'a> Foo(&'a int,&uint) -> uint >();
42 eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>,
43 for<'b> Foo(&int,&'b uint) -> uint >();
44 eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>,
45 Foo(&int,&uint) -> uint >();
47 // FIXME(#18992) Test lifetime elision in `()` form:
48 // eq::< for<'a,'b> Foo<(&'a int,), &'a int>,
49 // Foo(&int) -> &int >();
52 eq::< Foo<(),()>, Foo(char) >();
53 //~^ ERROR not implemented