-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clippy stores Symbol
s in lazy_static
#60848
Comments
cc @Manishearth |
The symbol list in |
how would I expose this list of symbols to my lints so that I can access individual symbols by name? |
// Defined by clippy (probably generated by a macro)
mod clippy_sim {
pub const my_sim1: Symbol = Symbol::from_u32(Symbol::NUM_PREINTERNED + 0);
pub const my_sim2: Symbol = Symbol::from_u32(Symbol::NUM_PREINTERNED + 1);
pub const my_sim3: Symbol = Symbol::from_u32(Symbol::NUM_PREINTERNED + 2);
...
}
fn rustc_interface_prefill_extra_callback() -> &[&str] { // Defined by clippy, called by `Interner::prefill` in rustc
&["my_sim1", "my_sim2", "my_sim3", ...]
} |
Should I take a crack at #39131 first? That's the real fix to most of our usage of Symbol, and if we're hardcoding this in rustc we might as well do it right. I suspect we'll have a couple left, though. |
That and the worry that implementing #39131 will be quite a bit of work and thus block rls for a week or more makes me prefer to do @petrochenkov's solution now, and address diagnostic items in its own timeframe. |
Oh, yeah, go ahead with any RLS quickfixes first. But we should try that out before trying to make this fix good. |
Citing @ehuss in #60819 (comment)
I assumed that rls kills only the
'tcx
interners and restarts atTyCtxt
creation time, but that assumption is apparently wrong.I don't want clippy to diverge from rustc's
Symbol
strategy and there's more than just paths that we're using them for (especially since more APIs are being turned into symbol-using ones).One idea would be for rustc's
symbols!
macro invocation to produce a macro (clippy_symbols
), which not only allows us to create a list of symbols statically by simply reserving 1000 symbols or so, but also has a list of all the already existing symbols and makes sure we don't duplicate any. The deduplication is currently achieved bySymbol::intern
being called in lazy statics.Alternatively we could probably setup some way for rls to tell its rustc invocation to only create a symbol table if there is already one and to not nuke the existing one on shutdown. This seems like the best short term option to me if there are no technical problems with it.
The text was updated successfully, but these errors were encountered: