Skip to content
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

lazy_static → once_cell → stabilized versions #3447

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

twwn
Copy link
Contributor

@twwn twwn commented Sep 27, 2024

Two cleanup commits:

  1. Replace the remaining lazy_static use with once_cell, effectively its replacement. The former is also unmaintained.
  2. Replace once_cell with stabilized LazyCell / LazyLock as much as possible.

See 2.'s commit message for details and the one remaining use.

@twwn twwn force-pushed the lazy_static-to-once_cell-to-stabilized branch from c3c89e7 to 08a2307 Compare September 27, 2024 13:46
Unify to once_cell, lazy_static's replacement. The latter in unmaintained.
@twwn twwn force-pushed the lazy_static-to-once_cell-to-stabilized branch from 9c8cffc to abaa795 Compare September 27, 2024 13:57
… possible

Since 1.80: rust-lang/rust#109736 and rust-lang/rust#98165

Non-Thread-Safe Lazy → std::cell::LazyCell https://doc.rust-lang.org/nightly/std/cell/struct.LazyCell.html

Thread-safe SyncLazy → std::sync::LazyLock https://doc.rust-lang.org/nightly/std/sync/struct.LazyLock.html

The compiler accepted LazyCell only in minilints.

The final use in rslib/src/log.rs couldn't be replaced since get_or_try_init has not yet been standardized: rust-lang/rust#109737
@twwn twwn force-pushed the lazy_static-to-once_cell-to-stabilized branch from abaa795 to 26cb101 Compare September 27, 2024 14:01
@twwn
Copy link
Contributor Author

twwn commented Sep 27, 2024

The repo check fails over…

MSRV (Minimum Supported Rust Version) is 1.65.0

… but rust-toolchain.toml says it's 1.81?

edit: Oh right, Cargo.toml has precedence. The second commit of this PR is too early, then?

Some of our deps require newer Rust versions, so this was misleading.

Updating the MSRV also allows us to use .inspect() on Option now
@dae
Copy link
Member

dae commented Sep 30, 2024

Not your fault, it was out of date. Thanks for looking into this!

@dae dae merged commit d9969a9 into ankitects:main Sep 30, 2024
1 check passed
@twwn twwn deleted the lazy_static-to-once_cell-to-stabilized branch October 1, 2024 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants