I have initialized some variables inside thread_local, but the variables were imported into another module a few days back. But right now they are unable to import. Kindly help. Thanks!
Formatting isn't working for me either inside thread_local, and I'm using a different editor. So it must be a problem with rustfmt. There are a bunch of rustfmt issues related to macros, so we probably need to manually format inside thread_local, at least for now.
As a general practice, I try to keep the amount of code that is inside macros as small as possible — because even if it were formatted properly, there are still other tools that won't know what to do with the macro. In this case, you could move the initialization to separate functions, which rustfmt can format fine:
I can reproduce this even with something as simple as thread_local!(static FOO: i32 = 0;). Rust-analyzer just doesn't recognize FOO as a variable and all suggestions based on that (importing it in another module, suggesting methods that can be called on it etc etc) don't work.