]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0435.md
Auto merge of #80790 - JohnTitor:rollup-js1noez, r=JohnTitor
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0435.md
1 A non-constant value was used in a constant expression.
2
3 Erroneous code example:
4
5 ```compile_fail,E0435
6 let foo = 42;
7 let a: [u8; foo]; // error: attempt to use a non-constant value in a constant
8 ```
9
10 'constant' means 'a compile-time value'.
11
12 More details can be found in the [Variables and Mutability] section of the book.
13
14 [Variables and Mutability]: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants
15
16 To fix this error, please replace the value with a constant. Example:
17
18 ```
19 let a: [u8; 42]; // ok!
20 ```
21
22 Or:
23
24 ```
25 const FOO: usize = 42;
26 let a: [u8; FOO]; // ok!
27 ```