Open
Description
I tried this code (Playground):
thread_local!(static FOO: usize = 0);
static init: usize = 0;
I expected to see this happen: code compile. Instead, this happened:
error[[E0530]](https://doc.rust-lang.org/stable/error-index.html#E0530): function parameters cannot shadow statics
--> src/lib.rs:1:1
|
1 | thread_local!(static FOO: usize = 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be named the same as a static
2 |
3 | static init: usize = 0;
| ----------------------- the static `init` is defined here
|
= note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0530`.
The workaround is obvious, simply don't have a static named init
. However, the broader issue is that this appears to violate macro hygienics: any change to the implementation to thread_local
could break my code in the future.
Meta
This happens on the playground for all channels (1.62.0, 1.63.0-beta.4, 1.64.0-nightly).