This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ // compile-flags: -Z mir-opt-level=2
2+ // build-pass
3+
4+ #![ feature( type_alias_impl_trait) ]
5+
6+ use std:: marker:: PhantomData ;
7+
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+ trait F { }
18+ impl F for ( ) { }
19+ type DummyT < T > = impl F ;
20+ fn _dummy_t < T > ( ) -> DummyT < T > { }
21+
22+ struct Phantom1 < T > ( PhantomData < T > ) ;
23+ struct Phantom2 < T > ( PhantomData < T > ) ;
24+ struct Scope < T > ( Phantom2 < DummyT < T > > ) ;
25+
26+ impl < T > Scope < T > {
27+ fn new ( ) -> Self {
28+ unimplemented ! ( )
29+ }
30+ }
31+
32+ impl < T > MyFrom < Phantom2 < T > > for Phantom1 < T > {
33+ type Error = ( ) ;
34+ fn my_from ( _: Phantom2 < T > ) -> Result < Self , Self :: Error > {
35+ unimplemented ! ( )
36+ }
37+ }
38+
39+ impl < T : MyFrom < Phantom2 < DummyT < U > > > , U > MyIndex < Phantom1 < T > > for Scope < U > {
40+ type O = T ;
41+ fn my_index ( self ) -> Self :: O {
42+ MyFrom :: my_from ( self . 0 ) . ok ( ) . unwrap ( )
43+ }
44+ }
45+
46+ fn main ( ) {
47+ let _pos: Phantom1 < DummyT < ( ) > > = Scope :: new ( ) . my_index ( ) ;
48+ }
You can’t perform that action at this time.
0 commit comments