]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/unboxed-closure-sugar-equiv.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / unboxed-closure-sugar-equiv.rs
CommitLineData
1a4d82fc
JJ
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.
4//
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.
10
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.
15
16#![feature(unboxed_closures)]
17#![allow(dead_code)]
18
85aaf69f
SL
19trait Foo<T> {
20 type Output;
21 fn dummy(&self, t: T, u: Self::Output);
1a4d82fc
JJ
22}
23
9346a6ac 24trait Eq<X: ?Sized> { }
1a4d82fc
JJ
25impl<X: ?Sized> Eq<X> for X { }
26fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
27
28fn test<'a,'b>() {
29 // No errors expected:
85aaf69f
SL
30 eq::< Foo<(),Output=()>, Foo() >();
31 eq::< Foo<(isize,),Output=()>, Foo(isize) >();
32 eq::< Foo<(isize,usize),Output=()>, Foo(isize,usize) >();
33 eq::< Foo<(isize,usize),Output=usize>, Foo(isize,usize) -> usize >();
34 eq::< Foo<(&'a isize,&'b usize),Output=usize>, Foo(&'a isize,&'b usize) -> usize >();
1a4d82fc
JJ
35
36 // Test that anonymous regions in `()` form are equivalent
37 // to fresh bound regions, and that we can intermingle
38 // named and anonymous as we choose:
85aaf69f 39 eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
1a4d82fc 40 for<'x,'y> Foo(&'x isize,&'y usize) -> usize >();
85aaf69f 41 eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
1a4d82fc 42 for<'x> Foo(&'x isize,&usize) -> usize >();
85aaf69f 43 eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
1a4d82fc 44 for<'y> Foo(&isize,&'y usize) -> usize >();
85aaf69f 45 eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>,
1a4d82fc
JJ
46 Foo(&isize,&usize) -> usize >();
47
48 // lifetime elision
85aaf69f 49 eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>,
1a4d82fc
JJ
50 Foo(&isize) -> &isize >();
51
52 // Errors expected:
85aaf69f
SL
53 eq::< Foo<(),Output=()>,
54 Foo(char) >();
54a0048b 55 //~^^ ERROR E0277
1a4d82fc
JJ
56}
57
58fn main() { }