]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/unboxed-closure-sugar-region.rs
rustc: always include elidable lifetimes in HIR types.
[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> {
21     type Output;
22     fn dummy(&'a self) -> &'a (T,Self::Output);
23 }
24
25 trait Eq<X: ?Sized> { fn is_of_eq_type(&self, x: &X) -> bool { true } }
26 impl<X: ?Sized> Eq<X> for X { }
27 fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
28
29 fn same_type<A,B:Eq<A>>(a: A, b: B) { }
30
31 fn test<'a,'b>() {
32     // Parens are equivalent to omitting default in angle.
33     eq::< Foo<(isize,),Output=()>,               Foo(isize)                      >();
34
35     // Here we specify 'static explicitly in angle-bracket version.
36     // Parenthesized winds up getting inferred.
37     eq::< Foo<'static, (isize,),Output=()>,      Foo(isize)                      >();
38 }
39
40 fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) {
41 //~^ ERROR wrong number of lifetime parameters: expected 1, found 0
42     // Here, the omitted lifetimes are expanded to distinct things.
43     same_type(x, y)
44 }
45
46 fn main() { }