]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs
Auto merge of #22517 - brson:relnotes, r=Gankro
[rust.git] / src / test / compile-fail / unboxed-closure-sugar-lifetime-elision.rs
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
19 trait Foo<T> {
20     type Output;
21     fn dummy(&self, t: T);
22 }
23
24 trait Eq<X: ?Sized> { }
25 impl<X: ?Sized> Eq<X> for X { }
26 fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
27
28 fn main() {
29     eq::< for<'a> Foo<(&'a isize,), Output=&'a isize>,
30           Foo(&isize) -> &isize                                   >();
31     eq::< for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>,
32           Foo(&isize) -> (&isize, &isize)                           >();
33
34     let _: Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier
35 }