Error code E0435

A non-constant value was used in a constant expression.

Erroneous code example:

#![allow(unused)]
fn main() {
let foo = 42;
let a: [u8; foo]; // error: attempt to use a non-constant value in a constant
}

'constant' means 'a compile-time value'.

More details can be found in the Variables and Mutability section of the book.

To fix this error, please replace the value with a constant. Example:

#![allow(unused)]
fn main() {
let a: [u8; 42]; // ok!
}

Or:

#![allow(unused)]
fn main() {
const FOO: usize = 42;
let a: [u8; FOO]; // ok!
}