about summary refs log tree commit diff
path: root/tests/ui/impl-trait/in-ctfe/fully_monomorphic_const_eval.rs
blob: 17233f7efc2ac3bc7be0cfae4054571dbc301958 (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
27
28
29
//! This test ensures that we do look at the hidden types of
//! opaque types during const eval in order to obtain the exact type
//! of associated 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
}

struct Foo<'a>(&'a ());
const NEED_REVEAL_ALL: usize = output(yeet());

fn promote_div() -> &'static usize {
    &(10 / NEED_REVEAL_ALL)
}
fn main() {}