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)]
19 use std::marker::PhantomFn;
23 fn dummy(&self, t: T, u: Self::Output);
26 trait Eq<X: ?Sized> : PhantomFn<(Self,X)> { }
27 impl<X: ?Sized> Eq<X> for X { }
28 fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
31 // No errors expected:
32 eq::< Foo<(),Output=()>, Foo() >();
33 eq::< Foo<(isize,),Output=()>, Foo(isize) >();
34 eq::< Foo<(isize,usize),Output=()>, Foo(isize,usize) >();
35 eq::< Foo<(isize,usize),Output=usize>, Foo(isize,usize) -> usize >();
36 eq::< Foo<(&'a isize,&'b usize),Output=usize>, Foo(&'a isize,&'b usize) -> usize >();
38 // Test that anonymous regions in `()` form are equivalent
39 // to fresh bound regions, and that we can intermingle
40 // named and anonymous as we choose:
41 eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
42 for<'x,'y> Foo(&'x isize,&'y usize) -> usize >();
43 eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
44 for<'x> Foo(&'x isize,&usize) -> usize >();
45 eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
46 for<'y> Foo(&isize,&'y usize) -> usize >();
47 eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
48 Foo(&isize,&usize) -> usize >();
51 eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>,
52 Foo(&isize) -> &isize >();
55 eq::< Foo<(),Output=()>,
57 //~^^ ERROR not implemented