summary refs log tree commit diff
path: root/tests/ui/impl-trait/in-ctfe/enum-discr.rs
blob: 8e4384adaa4cba44d1f1cc1b0973d9e428c55434 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! check that const eval can observe associated types of opaque types.
// check-pass
trait MyTrait: Copy {
    const ASSOC: usize;
}

impl MyTrait for u8 {
    const ASSOC: usize = 32;
}

const fn yeet() -> impl MyTrait {
    0u8
}

const fn output<T: MyTrait>(_: T) -> usize {
    <T as MyTrait>::ASSOC
}

#[repr(usize)]
enum Foo {
    Bar = output(yeet()),
}

fn main() {
    println!("{}", Foo::Bar as usize);
}