Skip to content

Commit 26c7635

Browse files
committed
Auto merge of #24893 - robinst:issue-24407-E0013, r=nrc
Part of #24407.
2 parents d4cedea + 6cdb57d commit 26c7635

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/librustc/diagnostics.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,25 @@ match x {
168168
```
169169
"##,
170170

171+
E0013: r##"
172+
Static and const variables can refer to other const variables. But a const
173+
variable cannot refer to a static variable. For example, `Y` cannot refer to `X`
174+
here:
175+
176+
```
177+
static X: i32 = 42;
178+
const Y: i32 = X;
179+
```
180+
181+
To fix this, the value can be extracted as a const and then used:
182+
183+
```
184+
const A: i32 = 42;
185+
static X: i32 = A;
186+
const Y: i32 = A;
187+
```
188+
"##,
189+
171190
E0015: r##"
172191
The only function calls allowed in static or constant expressions are enum
173192
variant constructors or struct constructors (for unit or tuple structs). This
@@ -462,7 +481,6 @@ register_diagnostics! {
462481
E0010,
463482
E0011,
464483
E0012,
465-
E0013,
466484
E0014,
467485
E0016,
468486
E0017,

0 commit comments

Comments
 (0)