Closed
Description
extern "C" {
thread_local! {
static FOO: u32 = 0;
}
}
This is of course invalid, thread_local expands to a static item with an initializer.
WARN rustc_errors::emitter Invalid span src/main.rs:4:12: 110:22 (#15), error=DistinctSources(DistinctSources { begin: (Real(LocalPath("src/main.rs")), BytePos(0)), end: (Real(Remapped { local_path: None, virtual_name: "/rustc/5ae769f06bbe2afc50cde219757a5915e61ba365/library/std/src/sys/common/thread_local/fast_local.rs" }), BytePos(415220)) })
error: extern items cannot be `const`
--> src/main.rs:4:12
|
4 | static FOO: u32 = 0;
| ____________-^^
5 | | }
6 | | }
7 | | }); }
... |
|
= note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html
error: incorrect `static` inside `extern` block
--> src/main.rs:4:12
|
2 | extern "C" {
| ---------- `extern` blocks define existing foreign statics and statics inside of them cannot have a body
3 | / thread_local! {
4 | | static FOO: u32 = 0;
| | ^^^ cannot have a body
5 | | }
| |___- the invalid body
|
= note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html
something's having fun with the span there