diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-08-06 11:21:29 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-06 11:21:29 +0900 |
| commit | 772db06e103f21761ffcc77d1099fbd60e88cdc0 (patch) | |
| tree | 6869e1413d612cb6f047b1e5059cdaf07a0274d8 /compiler/rustc_error_codes/src | |
| parent | 4b068dd657aad9e39be9cac1e8c3dee281c92cd4 (diff) | |
| parent | dc5f6d2e48d21dccbe58d755dd73cf9c6fb886b5 (diff) | |
| download | rust-772db06e103f21761ffcc77d1099fbd60e88cdc0.tar.gz rust-772db06e103f21761ffcc77d1099fbd60e88cdc0.zip | |
Rollup merge of #87715 - bhgomes:long-explanation-E0625, r=GuillaumeGomez
Add long error explanation for E0625 For #61137.
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0625.md | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 65999ba707c..719c2c6768b 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -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"), @@ -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 diff --git a/compiler/rustc_error_codes/src/error_codes/E0625.md b/compiler/rustc_error_codes/src/error_codes/E0625.md new file mode 100644 index 00000000000..7db857723cc --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0625.md @@ -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; +``` |
