]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closure-sugar-default.rs
Auto merge of #107054 - petrochenkov:effvisdoc3, r=GuillaumeGomez
[rust.git] / tests / ui / unboxed-closures / unboxed-closure-sugar-default.rs
1 // Test interaction between unboxed closure sugar and default type
2 // parameters (should be exactly as if angle brackets were used).
3
4 #![feature(unboxed_closures)]
5 #![allow(dead_code)]
6
7 trait Foo<T,V=T> {
8     type Output;
9     fn dummy(&self, t: T, v: V);
10 }
11
12 trait Eq<X: ?Sized> { fn same_types(&self, x: &X) -> bool { true } }
13 impl<X: ?Sized> Eq<X> for X { }
14 fn eq<A: ?Sized,B: ?Sized>() where A : Eq<B> { }
15
16 fn test<'a,'b>() {
17     // Parens are equivalent to omitting default in angle.
18     eq::<dyn Foo<(isize,), Output=()>, dyn Foo(isize)>();
19
20     // In angle version, we supply something other than the default
21     eq::<dyn Foo<(isize,), isize, Output=()>, dyn Foo(isize)>();
22     //~^ ERROR E0277
23
24     // Supply default explicitly.
25     eq::<dyn Foo<(isize,), (isize,), Output=()>, dyn Foo(isize)>();
26 }
27
28 fn main() { }