Skip to content

Replace lazy_static with std::sync::LazyLock - #306

Closed
jbgriesner wants to merge 2 commits into
rtk-ai:developfrom
jbgriesner:chore/replace-lazy-static-with-lazy-lock
Closed

jbgriesner wants to merge 2 commits into
rtk-ai:developfrom
jbgriesner:chore/replace-lazy-static-with-lazy-lock

Conversation

@jbgriesner

Copy link
Copy Markdown

Replaces all uses of the lazy_static crate with std::sync::LazyLock, which has been stable since Rust 1.80.

Motivation:

  • Removes one external dependency (lazy_static = "1.4")
  • Uses std

No behavior change. LazyLock initializes on first access, exactly like lazy_static. All regex patterns remain identical.

@FlorianBruniaux

Copy link
Copy Markdown
Contributor

Hi @jbgriesner, the migration is mechanically correct across all 14 files and the motivation is solid: one fewer external dependency, aligned with the standard library since Rust 1.80.

Two things needed before merge:

  1. std::sync::LazyLock stabilized in Rust 1.80 (July 2024). Please add rust-version = "1.80" to Cargo.toml so anyone on an older toolchain gets a clear error instead of a cryptic compile failure.

  2. CI shows 0/0 checks. Could you check why the workflow isn't triggering? We need cargo fmt --all && cargo clippy --all-targets && cargo test to pass before merge.

Minor note: next_cmd.rs and playwright_cmd.rs keep the statics inside function bodies. This is valid Rust but inconsistent with every other module in the codebase after this PR. Worth moving to module level for uniformity, though it's not a blocker.

@FlorianBruniaux

Copy link
Copy Markdown
Contributor

Hey @jbgriesner, heads up: PR #349 (TOML filter DSL) uses lazy_static\! in src/toml_filter.rs. If your LazyLock migration merges first, we'll switch to LazyLock directly — cleaner result. No action needed from you, just FYI.

jbgriesner added a commit to jbgriesner/rtk that referenced this pull request Mar 9, 2026
- Add rust-version = "1.80" to Cargo.toml: LazyLock was stabilized in
  Rust 1.80, this gives a clear error instead of cryptic compile failure
  on older toolchains
- Move LazyLock statics in next_cmd.rs and playwright_cmd.rs from
  function bodies to module level, consistent with every other module
  in the codebase
- Remove unused ROUTE_PATTERN static (dead code cleanup)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@jbgriesner
jbgriesner force-pushed the chore/replace-lazy-static-with-lazy-lock branch from 0cae53d to f8d090a Compare March 9, 2026 21:31
@jbgriesner

Copy link
Copy Markdown
Author
  1. CI shows 0/0 checks. Could you check why the workflow isn't triggering? We need cargo fmt --all && cargo clippy --all-targets && cargo test to pass before merge.

The 0/0 CI checks are a GitHub limitation with fork PRs: workflows run from the fork's own .github/workflows/ directory, not from the upstream repo. Since my fork doesn't replicate the upstream CI setup, no checks trigger automatically.

I've verified locally that all three gates pass: cargo fmt --all && cargo clippy --all-targets && cargo test
430 tests pass, no clippy errors.

@CLAassistant

CLAassistant commented Mar 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pszymkowiak

Copy link
Copy Markdown
Collaborator

Hi! Two things needed before we can review:

  1. Retarget to develop — this PR targets master, but all PRs should target develop. You can change the base branch in the PR settings (right sidebar).
  2. Sign the CLA — if not already done, please sign at https://cla-assistant.io/rtk-ai/rtk

Thanks!

@jbgriesner
jbgriesner changed the base branch from master to develop March 26, 2026 11:02
@aeppling

Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 3, 2026
@KuSh

KuSh commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the cleanup. This landed as PR #3244 (merged 2026-07-28), which replaced every lazy_static! block with std::sync::LazyLock and removed the dependency from Cargo.toml, so develop no longer references lazy_static anywhere. The file layout also changed since this branch was opened, with the command modules moved under src/cmds and shared code under src/core. If you find a spot that still compiles a regex eagerly or was missed by that pass, please comment here or reopen.

@KuSh KuSh closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants