File tree 2 files changed +80
-0
lines changed
src/test/ui/higher-rank-trait-bounds/normalize-under-binder
2 files changed +80
-0
lines changed Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ #![ feature( generic_associated_types) ]
4
+
5
+ use std:: marker:: PhantomData ;
6
+
7
+ trait Family : Sized {
8
+ type Item < ' a > ;
9
+
10
+ fn apply_all < F > ( & self , f : F )
11
+ where
12
+ F : FamilyItemFn < Self > { }
13
+ }
14
+
15
+ struct Array < T > ( PhantomData < T > ) ;
16
+
17
+ impl < T : ' static > Family for Array < T > {
18
+ type Item < ' a > = & ' a T ;
19
+ }
20
+
21
+ trait FamilyItemFn < T : Family > {
22
+ fn apply ( & self , item : T :: Item < ' _ > ) ;
23
+ }
24
+
25
+ impl < T , F > FamilyItemFn < T > for F
26
+ where
27
+ T : Family ,
28
+ for < ' a > F : Fn ( T :: Item < ' a > )
29
+ {
30
+ fn apply ( & self , item : T :: Item < ' _ > ) {
31
+ ( * self ) ( item) ;
32
+ }
33
+ }
34
+
35
+ fn process < T : ' static > ( array : Array < T > ) {
36
+ // Works
37
+ array. apply_all ( |x : & T | { } ) ;
38
+
39
+ // ICE: NoSolution
40
+ array. apply_all ( |x : <Array < T > as Family >:: Item < ' _ > | { } ) ;
41
+ }
42
+
43
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ //check-pass
2
+
3
+ #![ feature( generic_associated_types) ]
4
+
5
+ trait Yokeable < ' a > : ' static {
6
+ type Output : ' a ;
7
+ }
8
+
9
+ trait IsCovariant < ' a > { }
10
+
11
+ struct Yoke < Y : for < ' a > Yokeable < ' a > > {
12
+ data : Y ,
13
+ }
14
+
15
+ impl < Y : for < ' a > Yokeable < ' a > > Yoke < Y > {
16
+ fn project < Y2 : for < ' a > Yokeable < ' a > > ( & self , _f : for <' a > fn ( <Y as Yokeable < ' a > >:: Output , & ' a ( ) )
17
+ -> <Y2 as Yokeable < ' a > >:: Output ) -> Yoke < Y2 > {
18
+
19
+ unimplemented ! ( )
20
+ }
21
+ }
22
+
23
+ fn _upcast < Y > ( x : Yoke < Y > ) -> Yoke < Box < dyn IsCovariant < ' static > + ' static > > where
24
+ Y : for < ' a > Yokeable < ' a > ,
25
+ for < ' a > <Y as Yokeable < ' a > >:: Output : IsCovariant < ' a >
26
+ {
27
+ x. project ( |data, _| {
28
+ Box :: new ( data)
29
+ } )
30
+ }
31
+
32
+
33
+ impl < ' a > Yokeable < ' a > for Box < dyn IsCovariant < ' static > + ' static > {
34
+ type Output = Box < dyn IsCovariant < ' a > + ' a > ;
35
+ }
36
+
37
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments