3 #![feature(associated_type_bounds)]
4 #![feature(impl_trait_in_bindings)]
5 //~^ WARNING `impl_trait_in_bindings` is incomplete
6 #![allow(non_upper_case_globals)]
10 trait Tr1 { type As1; fn mk(&self) -> Self::As1; }
11 trait Tr2
<'a
> { fn tr2(self) -> &'a Self; }
13 fn assert_copy
<T
: Copy
>(x
: T
) { let _x = x; let _x = x; }
14 fn assert_static
<T
: '
static>(_
: T
) {}
15 fn assert_forall_tr2
<T
: for<'a
> Tr2
<'a
>>(_
: T
) {}
17 #[derive(Copy, Clone)]
19 #[derive(Copy, Clone)]
21 impl Tr1
for S1 { type As1 = S2; fn mk(&self) -> Self::As1 { S2 }
}
23 const cdef_et1
: impl Copy
+ Tr1
<As1
: Copy
> = {
24 let x
: impl Copy
+ Tr1
<As1
: Copy
> = S1
;
27 static sdef_et1
: impl Copy
+ Tr1
<As1
: Copy
> = cdef_et1
;
28 pub fn use_et1() { assert_copy(cdef_et1.mk()); assert_copy(sdef_et1.mk()); }
30 const cdef_et2
: impl Tr1
<As1
: '
static> = {
31 let x
: impl Tr1
<As1
: '
static> = S1
;
34 static sdef_et2
: impl Tr1
<As1
: '
static> = cdef_et2
;
35 pub fn use_et2() { assert_static(cdef_et2.mk()); assert_static(sdef_et2.mk()); }
37 const cdef_et3
: impl Tr1
<As1
: Clone
+ Iterator
<Item
: Add
<u8, Output
: Into
<u8>>>> = {
40 type As1
= core
::ops
::Range
<u8>;
41 fn mk(&self) -> Self::As1 { 0..10 }
43 let x
: impl Tr1
<As1
: Clone
+ Iterator
<Item
: Add
<u8, Output
: Into
<u8>>>> = A
;
47 let _0
= cdef_et3
.mk().clone();
53 assert_eq
!(s
, (0..10).map(|x
| x
+ 1).sum());
56 const cdef_et4
: impl Copy
+ Tr1
<As1
: for<'a
> Tr2
<'a
>> = {
57 #[derive(Copy, Clone)]
61 fn mk(&self) -> A { A }
63 impl<'a
> Tr2
<'a
> for A
{
64 fn tr2(self) -> &'a
Self { &A }
66 let x
: impl Copy
+ Tr1
<As1
: for<'a
> Tr2
<'a
>> = A
;
70 static sdef_et4
: impl Copy
+ Tr1
<As1
: for<'a
> Tr2
<'a
>> = cdef_et4
;
71 pub fn use_et4() { assert_forall_tr2(cdef_et4.mk()); assert_forall_tr2(sdef_et4.mk()); }