Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ E0621: include_str!("./error_codes/E0621.md"),
E0622: include_str!("./error_codes/E0622.md"),
E0623: include_str!("./error_codes/E0623.md"),
E0624: include_str!("./error_codes/E0624.md"),
E0625: include_str!("./error_codes/E0625.md"),
E0626: include_str!("./error_codes/E0626.md"),
E0627: include_str!("./error_codes/E0627.md"),
E0628: include_str!("./error_codes/E0628.md"),
Expand Down Expand Up @@ -622,7 +623,6 @@ E0783: include_str!("./error_codes/E0783.md"),
// E0611, // merged into E0616
// E0612, // merged into E0609
// E0613, // Removed (merged with E0609)
E0625, // thread-local statics cannot be accessed at compile-time
// E0629, // missing 'feature' (rustc_const_unstable)
// E0630, // rustc_const_unstable attribute must be paired with stable/unstable
// attribute
Expand Down
28 changes: 28 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0625.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
A compile-time const variable is referring to a thread-local static variable.

Erroneous code example:

```compile_fail,E0625
#![feature(thread_local)]
#[thread_local]
static X: usize = 12;
const Y: usize = 2 * X;
```

Static and const variables can refer to other const variables but a const
variable cannot refer to a thread-local static variable. In this example,
`Y` cannot refer to `X`. To fix this, the value can be extracted as a const
and then used:

```
#![feature(thread_local)]
const C: usize = 12;
#[thread_local]
static X: usize = C;
const Y: usize = 2 * C;
```
1 change: 1 addition & 0 deletions src/test/ui/thread-local-in-ctfe.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ LL | A

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0625`.
2 changes: 1 addition & 1 deletion src/test/ui/thread-local-static.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ LL | std::mem::swap(x, &mut STATIC_VAR_2)

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0013, E0133, E0658.
Some errors have detailed explanations: E0013, E0133, E0625, E0658.
For more information about an error, try `rustc --explain E0013`.