File tree 1 file changed +49
-0
lines changed
src/test/ui/type-alias-impl-trait
1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ // build-pass
2
+
3
+ #![ feature( type_alias_impl_trait) ]
4
+
5
+ use std:: marker:: PhantomData ;
6
+
7
+ /* copied Index and TryFrom for convinience (and simplicity) */
8
+ trait MyIndex < T > {
9
+ type O ;
10
+ fn my_index ( self ) -> Self :: O ;
11
+ }
12
+ trait MyFrom < T > : Sized {
13
+ type Error ;
14
+ fn my_from ( value : T ) -> Result < Self , Self :: Error > ;
15
+ }
16
+
17
+ /* MCVE starts here */
18
+ trait F { }
19
+ impl F for ( ) { }
20
+ type DummyT < T > = impl F ;
21
+ fn _dummy_t < T > ( ) -> DummyT < T > { }
22
+
23
+ struct Phantom1 < T > ( PhantomData < T > ) ;
24
+ struct Phantom2 < T > ( PhantomData < T > ) ;
25
+ struct Scope < T > ( Phantom2 < DummyT < T > > ) ;
26
+
27
+ impl < T > Scope < T > {
28
+ fn new ( ) -> Self {
29
+ unimplemented ! ( )
30
+ }
31
+ }
32
+
33
+ impl < T > MyFrom < Phantom2 < T > > for Phantom1 < T > {
34
+ type Error = ( ) ;
35
+ fn my_from ( _: Phantom2 < T > ) -> Result < Self , Self :: Error > {
36
+ unimplemented ! ( )
37
+ }
38
+ }
39
+
40
+ impl < T : MyFrom < Phantom2 < DummyT < U > > > , U > MyIndex < Phantom1 < T > > for Scope < U > {
41
+ type O = T ;
42
+ fn my_index ( self ) -> Self :: O {
43
+ MyFrom :: my_from ( self . 0 ) . ok ( ) . unwrap ( )
44
+ }
45
+ }
46
+
47
+ fn main ( ) {
48
+ let _pos: Phantom1 < DummyT < ( ) > > = Scope :: new ( ) . my_index ( ) ;
49
+ }
You can’t perform that action at this time.
0 commit comments