]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/unboxed-closure-sugar-region.rs
Update compile fail tests to use isize.
[rust.git] / src / test / compile-fail / unboxed-closure-sugar-region.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 interaction between unboxed closure sugar and region
12 // parameters (should be exactly as if angle brackets were used
13 // and regions omitted).
14
15 #![feature(unboxed_closures)]
16 #![allow(dead_code)]
17
18 use std::marker;
19
20 trait Foo<'a,T,U> {
21     fn dummy(&'a self) -> &'a (T,U);
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 same_type<A,B:Eq<A>>(a: A, b: B) { }
29
30 fn test<'a,'b>() {
31     // Parens are equivalent to omitting default in angle.
32     eq::< Foo<(isize,),()>,               Foo(isize)                      >();
33
34     // Here we specify 'static explicitly in angle-bracket version.
35     // Parenthesized winds up getting inferred.
36     eq::< Foo<'static, (isize,),()>,      Foo(isize)                      >();
37 }
38
39 fn test2(x: &Foo<(isize,),()>, y: &Foo(isize)) {
40     // Here, the omitted lifetimes are expanded to distinct things.
41     same_type(x, y) //~ ERROR cannot infer
42 }
43
44 fn main() { }