]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closure-sugar-region.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / unboxed-closures / unboxed-closure-sugar-region.rs
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;
12     fn dummy(&'a self) -> &'a (T,Self::Output);
13 }
14
15 trait Eq<X: ?Sized> { fn is_of_eq_type(&self, x: &X) -> bool { true } }
16 impl<X: ?Sized> Eq<X> for X { }
17 fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
18
19 fn same_type<A,B:Eq<A>>(a: A, b: B) { }
20
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
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
36 fn main() { }