]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_error_codes/src/error_codes/E0013.md
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0013.md
1 Static and const variables can refer to other const variables. But a const
2 variable cannot refer to a static variable.
3
4 Erroneous code example:
5
6 ```compile_fail,E0013
7 static X: i32 = 42;
8 const Y: i32 = X;
9 ```
10
11 In this example, `Y` cannot refer to `X` here. To fix this, the value can be
12 extracted as a const and then used:
13
14 ```
15 const A: i32 = 42;
16 static X: i32 = A;
17 const Y: i32 = A;
18 ```