1 // Test interaction between unboxed closure sugar and region
2 // parameters (should be exactly as if angle brackets were used
3 // and regions omitted).
4 
5 #![feature(unboxed_closures)]
6 #![allow(dead_code)]
7 
8 use std::marker;
9 
10 trait Foo<'a,T> {
11     type Output;
dummy(&'a self) -> &'a (T,Self::Output)12     fn dummy(&'a self) -> &'a (T,Self::Output);
13 }
14 
is_of_eq_type(&self, x: &X) -> bool15 trait Eq<X: ?Sized> { fn is_of_eq_type(&self, x: &X) -> bool { true } }
16 impl<X: ?Sized> Eq<X> for X { }
eq<A: ?Sized,B: ?Sized +Eq<A>>()17 fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
18 
same_type<A,B:Eq<A>>(a: A, b: B)19 fn same_type<A,B:Eq<A>>(a: A, b: B) { }
20 
test<'a,'b>()21 fn test<'a,'b>() {
22     // Parens are equivalent to omitting default in angle.
23     eq::< dyn Foo<(isize,),Output=()>,               dyn Foo(isize)                      >();
24 
25     // Here we specify 'static explicitly in angle-bracket version.
26     // Parenthesized winds up getting inferred.
27     eq::< dyn Foo<'static, (isize,),Output=()>,      dyn Foo(isize)                      >();
28 }
29 
test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize))30 fn test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize)) {
31     //~^ ERROR this trait takes 1 lifetime argument but 0 lifetime arguments were supplied
32     // Here, the omitted lifetimes are expanded to distinct things.
33     same_type(x, y)
34 }
35 
main()36 fn main() { }
37