]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs
Rollup merge of #106244 - atouchet:readme3, r=workingjubilee
[rust.git] / tests / ui / unboxed-closures / unboxed-closure-sugar-lifetime-elision.rs
1 // Test that the unboxed closure sugar can be used with an arbitrary
2 // struct type and that it is equivalent to the same syntax using
3 // angle brackets. This test covers only simple types and in
4 // particular doesn't test bound regions.
5
6 #![feature(unboxed_closures)]
7 #![allow(dead_code)]
8
9 use std::marker;
10
11 trait Foo<T> {
12     type Output;
13     fn dummy(&self, t: T);
14 }
15
16 trait Eq<X: ?Sized> { }
17 impl<X: ?Sized> Eq<X> for X { }
18 fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
19
20 fn main() {
21     eq::< dyn for<'a> Foo<(&'a isize,), Output=&'a isize>,
22           dyn Foo(&isize) -> &isize                                   >();
23     eq::< dyn for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>,
24           dyn Foo(&isize) -> (&isize, &isize)                           >();
25
26     let _: dyn Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier
27 }