]> git.lizzy.rs Git - rust.git/blob - tests/ui/const-generics/generic_const_exprs/no_where_clause.rs
Auto merge of #106711 - albertlarsan68:use-ci-llvm-when-lld, r=jyn514
[rust.git] / tests / ui / const-generics / generic_const_exprs / no_where_clause.rs
1 #![feature(generic_const_exprs)]
2 #![allow(incomplete_features, unused)]
3
4 const fn complex_maths(n : usize) -> usize {
5   2 * n + 1
6 }
7
8 pub struct Example<const N: usize> {
9   a: [f32; N],
10   b: [f32; complex_maths(N)],
11   //~^ ERROR unconstrained generic
12 }
13
14 impl<const N: usize> Example<N> {
15   pub fn new() -> Self {
16     Self {
17       a: [0.; N],
18       b: [0.; complex_maths(N)],
19     }
20   }
21 }
22
23 impl Example<2> {
24   pub fn sum(&self) -> f32 {
25     self.a.iter().sum::<f32>() + self.b.iter().sum::<f32>()
26   }
27 }
28
29 fn main() {}