]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/issue-104396.rs
Rollup merge of #106949 - compiler-errors:is-poly, r=BoxyUwU
[rust.git] / tests / ui / consts / issue-104396.rs
1 // compile-flags: -Zmir-opt-level=3
2 // check-pass
3
4 #![feature(generic_const_exprs)]
5 //~^ WARN the feature `generic_const_exprs` is incomplete
6
7 #[inline(always)]
8 fn from_fn_1<const N: usize, F: FnMut(usize) -> f32>(mut f: F) -> [f32; N] {
9     let mut result = [0.0; N];
10     let mut i = 0;
11     while i < N {
12         result[i] = f(i);
13         i += 1;
14     }
15     result
16 }
17
18 pub struct TestArray<const N: usize>
19 where
20     [(); N / 2]:,
21 {
22     array: [f32; N / 2],
23 }
24
25 impl<const N: usize> TestArray<N>
26 where
27     [(); N / 2]:,
28 {
29     fn from_fn_2<F: FnMut(usize) -> f32>(f: F) -> Self {
30         Self { array: from_fn_1(f) }
31     }
32 }
33
34 fn main() {
35     TestArray::<4>::from_fn_2(|i| 0.0);
36 }