chore: migrate once_cell to std::sync::LazyLock (bumps MSRV to 1.85)#972
chore: migrate once_cell to std::sync::LazyLock (bumps MSRV to 1.85)#972anikettuli wants to merge 1 commit intoStremio:developmentfrom
Conversation
`std::sync::LazyLock` (stabilized in Rust 1.80) provides the same behavior as `once_cell::sync::Lazy` without a third-party dependency. Migrating cuts one crate from every build and tightens the stdlib alignment story. `OnceCell` / `OnceLock` usage was not present in the workspace, so this PR focuses purely on the `Lazy` migration. Changes: - 10 files: `use once_cell::sync::Lazy;` -> `use std::sync::LazyLock;`, and every `Lazy::new(...)` / `: Lazy<T>` renamed to `LazyLock::new(...)` / `: LazyLock<T>`. No behavior change - API is drop-in identical. - Cargo.toml (root): drop `once_cell = "1"`, bump `rust-version` to 1.85. - stremio-core-web/Cargo.toml: drop `once_cell = "1"`. - stremio-watched-bitfield/Cargo.toml: bump `rust-version` to 1.85 for consistency with the workspace. - .github/workflows/msrv.yml: RUST_MSRV_VERSION to 1.85. The MSRV bump is required because `LazyLock` needs Rust 1.80+. Bumping to 1.85 matches the CI matrix (build.yml uses stable) so there is no fresh floor to enforce separately. If Stremio#970 (the standalone MSRV bump PR) lands first, the MSRV changes here become no-ops; if this lands first, Stremio#970 becomes a no-op. Either merge order is clean. Touched files: src/addon_transport/http_transport/http_transport.rs src/constants.rs src/models/ctx/update_notifications.rs src/models/player.rs src/unit_tests/ctx/notifications/update_notifications.rs src/unit_tests/ctx/sync_library_with_api.rs src/unit_tests/deep_links/library_item_deep_links.rs src/unit_tests/env.rs stremio-core-web/src/env.rs stremio-core-web/src/stremio_core_web.rs Verified locally (Rust 1.85.1 stable-x86_64-pc-windows-gnu): cargo test -p stremio-core --lib -> 202 passed, 0 failed cargo test -p stremio-watched-bitfield -> 7 passed, 0 failed cargo clippy --all --no-deps -D warnings -> clean cargo fmt --check -> clean
stremio-core-web prebuildPrebuild artifact published by the Paste one of these into Release "@stremio/stremio-core-web": "https://stremio.github.io/stremio-core/stremio-core-web/claude/once-cell-to-std/stremio-stremio-core-web-0.56.3.tgz"Dev "@stremio/stremio-core-web": "https://stremio.github.io/stremio-core/stremio-core-web/claude/once-cell-to-std/dev/stremio-stremio-core-web-0.56.3.tgz" |
There was a problem hiding this comment.
Pull request overview
This PR migrates the workspace from once_cell::sync::Lazy to std::sync::LazyLock, removes the direct once_cell dependency from manifests, and bumps the declared MSRV to Rust 1.85 (including the MSRV CI workflow).
Changes:
- Replace
once_cell::sync::Lazystatics withstd::sync::LazyLockacross core, web, and unit test modules. - Remove
once_cell = "1"from the relevantCargo.tomlmanifests and update MSRV metadata/CI. - Update
Cargo.lockaccordingly (including lockfile format version bump).
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml |
Bumps MSRV to 1.85 and removes direct once_cell dependency. |
stremio-watched-bitfield/Cargo.toml |
Aligns crate MSRV to 1.85. |
stremio-core-web/Cargo.toml |
Removes direct once_cell dependency. |
.github/workflows/msrv.yml |
Updates MSRV CI toolchain to 1.85. |
Cargo.lock |
Removes once_cell from affected crates’ direct dependency lists; lockfile version updates. |
src/constants.rs |
Converts global Lazy<...> statics to LazyLock<...>. |
src/models/player.rs |
Converts PUSH_TO_LIBRARY_EVERY to LazyLock. |
src/models/ctx/update_notifications.rs |
Converts REQUEST_LAST_VIDEOS_EVERY to LazyLock. |
src/addon_transport/http_transport/http_transport.rs |
Converts CINEMETA_ADDONS_CATALOG_URL to LazyLock. |
src/unit_tests/env.rs |
Migrates unit-test globals from Lazy to LazyLock. |
src/unit_tests/deep_links/library_item_deep_links.rs |
Migrates test fixtures to LazyLock. |
src/unit_tests/ctx/sync_library_with_api.rs |
Migrates test fixtures to LazyLock. |
src/unit_tests/ctx/notifications/update_notifications.rs |
Migrates test fixtures to LazyLock. |
stremio-core-web/src/env.rs |
Migrates web env statics to LazyLock. |
stremio-core-web/src/stremio_core_web.rs |
Migrates runtime static to LazyLock. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| use regex::Regex; | ||
| use serde::{Deserialize, Serialize}; | ||
| use serde_json::json; | ||
| use std::sync::LazyLock; |
| use futures::{channel::mpsc::Receiver, future, Future, StreamExt, TryFutureExt}; | ||
| use once_cell::sync::Lazy; | ||
| use serde::{Deserialize, Serialize}; | ||
| use std::sync::LazyLock; |
|
Superseded by #973 — the five dead-weight/MSRV modernizations are bundled there to avoid five near-identical Cargo.toml / Cargo.lock merges. Each change remains a distinct commit for piecewise review. |
Summary
Migrates every
once_cell::sync::Lazyusage in the workspace tostd::sync::LazyLock(stabilized in Rust 1.80), dropsonce_cellfrom bothCargo.tomlmanifests, and bumps the declared MSRV from1.77→1.85to satisfy theLazyLockrequirement.Why this change
std::sync::LazyLockis an exact drop-in replacement foronce_cell::sync::Lazyon supported toolchains — same API, same behavior, same performance characteristics. Keepingonce_cellaround for a feature the standard library now ships is pure dependency bloat.Effect
Cargo.lock.once_cell::sync::LazywhenLazyLockdoes the same job.LazyLockandLazyuse identicalOnceLockinternals; performance is equivalent.Changes
Code — 10 files, mechanical replacement
For every file below:
use once_cell::sync::Lazy;→use std::sync::LazyLock;, and everyLazy::new(...)/Lazy<T>renamed toLazyLock::new(...)/LazyLock<T>. Thestaticitems themselves (e.g.,CINEMETA_URL,FETCH_HANDLER) have the exact same type semantics as before.src/addon_transport/http_transport/http_transport.rssrc/constants.rssrc/models/ctx/update_notifications.rssrc/models/player.rssrc/unit_tests/ctx/notifications/update_notifications.rssrc/unit_tests/ctx/sync_library_with_api.rssrc/unit_tests/deep_links/library_item_deep_links.rssrc/unit_tests/env.rsstremio-core-web/src/env.rsstremio-core-web/src/stremio_core_web.rsOnceCell/OnceLockusage was not present in this workspace, so that half of the usual migration was not needed.Manifest
Cargo.toml(root) — droponce_cell = "1", bumprust-version"1.77"→"1.85", fix an outdated comment that referencedmsrv.yaml.stremio-core-web/Cargo.toml— droponce_cell = "1".stremio-watched-bitfield/Cargo.toml— bumprust-version"1.60"→"1.85"for workspace-wide consistency..github/workflows/msrv.yml—RUST_MSRV_VERSION: '1.77'→'1.85'.Why the MSRV bump
LazyLockwas stabilized in Rust 1.80. Setting MSRV to 1.85 (rather than the minimum 1.80) matches thebuild.ymlCI matrix and leaves some headroom. It overlaps perfectly with #970 (the standalone MSRV bump PR) — whichever merges first, the other's MSRV diff becomes a no-op on rebase.Dependency on other PRs
Test plan
Verified locally (Rust 1.85.1
stable-x86_64-pc-windows-gnu):cargo test -p stremio-core --lib— 202 passed, 0 failedcargo test -p stremio-watched-bitfield— 7 passed, 0 failedcargo clippy --all --no-deps -- -D warnings— cleancargo fmt --check— clean