File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
src/test/ui/impl-trait/in-ctfe Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ trait MyTrait : Copy {
2+ const ASSOC : usize ;
3+ }
4+
5+ impl MyTrait for u8 {
6+ const ASSOC : usize = 32 ;
7+ }
8+
9+ const fn yeet ( ) -> impl MyTrait {
10+ 0u8
11+ }
12+
13+ const fn output < T : MyTrait > ( _: T ) -> usize {
14+ <T as MyTrait >:: ASSOC
15+ }
16+
17+ fn main ( ) {
18+ let x = [ 0u8 ; output ( yeet ( ) ) ] ;
19+ println ! ( "{:?}" , x) ;
20+ }
Original file line number Diff line number Diff line change 1+ trait MyTrait : Copy {
2+ const ASSOC : usize ;
3+ }
4+
5+ impl MyTrait for u8 {
6+ const ASSOC : usize = 32 ;
7+ }
8+
9+ const fn yeet ( ) -> impl MyTrait {
10+ 0u8
11+ }
12+
13+ const fn output < T : MyTrait > ( _: T ) -> usize {
14+ <T as MyTrait >:: ASSOC
15+ }
16+
17+ #[ repr( usize ) ]
18+ enum Foo {
19+ Bar = output ( yeet ( ) ) ,
20+ }
21+
22+ fn main ( ) {
23+ println ! ( "{}" , Foo :: Bar as usize ) ;
24+ }
You can’t perform that action at this time.
0 commit comments