File tree 5 files changed +79
-0
lines changed
5 files changed +79
-0
lines changed Original file line number Diff line number Diff line change 1
1
// ignore-tidy-linelength
2
2
// ignore-wasm32-bare compiled with panic=abort by default
3
+ // compile-flags: -Z mir-opt-level=3
3
4
#![ feature( box_syntax) ]
4
5
5
6
fn main ( ) {
Original file line number Diff line number Diff line change
1
+ // build-pass
2
+
3
+ trait AssociatedConstant {
4
+ const DATA : ( ) ;
5
+ }
6
+
7
+ impl < F , T > AssociatedConstant for F
8
+ where
9
+ F : FnOnce ( ) -> T ,
10
+ T : AssociatedConstant ,
11
+ {
12
+ const DATA : ( ) = T :: DATA ;
13
+ }
14
+
15
+ impl AssociatedConstant for ( ) {
16
+ const DATA : ( ) = ( ) ;
17
+ }
18
+
19
+ fn foo ( ) -> impl AssociatedConstant {
20
+ ( )
21
+ }
22
+
23
+ fn get_data < T : AssociatedConstant > ( _: T ) -> & ' static ( ) {
24
+ & T :: DATA
25
+ }
26
+
27
+ fn main ( ) {
28
+ get_data ( foo) ;
29
+ }
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