Skip to content

use std::lazy::SyncLazy instead of lazy_static #5251

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

light4
Copy link
Contributor

@light4 light4 commented Mar 3, 2022

Can we use the nightly feature once_cell?

@ytmimi
Copy link
Contributor

ytmimi commented Mar 3, 2022

Thanks for your first PR!

Can we use the nightly feature once_cell?

Speaking for myself, I don't see why we couldn't use it. I'm personally not too familiar with the once_cell feature. It would be great if you could elaborate on the advantages to using this over lazy_static!. Is the idea just to replace a 3rd party dependency?

@light4
Copy link
Contributor Author

light4 commented Mar 3, 2022

  1. Remove a 3rd party dependency
  2. Macro free
  3. When the feature is stabled, we can just switch over it
  4. Performance improvement according to this use once_cell instead of lazy_static async-rs/async-std#406

This is the once_cell tracing issue: rust-lang/rust#74465

@ytmimi
Copy link
Contributor

ytmimi commented Mar 3, 2022

That all sounds awesome! Thanks for including those links. I'll be sure to give them a read 😄

@calebcartwright
Copy link
Member

calebcartwright commented Mar 16, 2022

Thanks for the PR!

We've historically stayed away from any gated features (obviously excluding rustc_private which we need for consuming compiler internals). However, while I'm not sure I'm ready to take the plunge into using unstable features I also think we're kidding ourselves if we continue that refrain based on hopes of being able to build with a stable compiler some day.

That being said, I'm still on the fence about this one as I don't think it buys us all that much just yet, given that lazy_static is still in our build graph due to various transitive dependencies and we'd technically be pulling in once_cell too.

I concur that this is the right move strategically, but not quite convinced yet that it's all that beneficial today. Will leave it parked for a bit in case I change my mind.

@ytmimi
Copy link
Contributor

ytmimi commented Feb 17, 2024

This one is still on hold, but I wanted to mention that the latest tracking issue for this is rust-lang/rust#109736.

@ytmimi
Copy link
Contributor

ytmimi commented Aug 14, 2024

lazy_static was removed in #6154

@ytmimi ytmimi closed this Aug 14, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants