about summary refs log tree commit diff
path: root/src/test/ui/const-generics/min_const_generics/complex-expression.rs
blob: 201af9fcef382ac0232dd64b3009b6d2e28160bf (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
30
31
32
33
34
35
36
37
#![feature(min_const_generics)]

fn test<const N: usize>() {}

fn ok<const M: usize>() -> [u8; M] {
    [0; { M }]
}

struct Break0<const N: usize>([u8; { N + 1 }]);
//~^ ERROR generic parameters must not be used inside of non trivial constant values

struct Break1<const N: usize>([u8; { { N } }]);
//~^ ERROR generic parameters must not be used inside of non trivial constant values

fn break2<const N: usize>() {
    let _: [u8; N + 1];
    //~^ ERROR generic parameters must not be used inside of non trivial constant values
}

fn break3<const N: usize>() {
    let _ = [0; N + 1];
    //~^ ERROR generic parameters must not be used inside of non trivial constant values
}

trait Foo {
    const ASSOC: usize;
}

impl<const N: usize> Foo for [u8; N] {
    const ASSOC: usize = N + 1;
    //~^ ERROR generic parameters must not be used inside of non trivial constant values
    // FIXME(min_const_generics): We probably have to allow this as we can
    // already allow referencing type parameters here on stable.
}


fn main() {}