Skip to content

refactor: replace lazy_static with LazyLock - #3244

Merged
TaKO8Ki merged 2 commits into
rtk-ai:developfrom
TaKO8Ki:refactor/replace-lazy-static
Jul 27, 2026
Merged

TaKO8Ki merged 2 commits into
rtk-ai:developfrom
TaKO8Ki:refactor/replace-lazy-static

Conversation

@TaKO8Ki

@TaKO8Ki TaKO8Ki commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Since LazyLock has been stable since Rust 1.80 and RTK's MSRV is Rust 1.91, there is no longer a project-specific reason to use the external lazy_static macro. In addition, #3249 removed nested lazy_static dependency by updating colored crate.

  • Replace lazy_static! declarations with std::sync::LazyLock without intended behavior changes.
  • Remove lazy_static dependency and update related documentation.
  • Remove three unused regex definitions exposed by dead_code checks.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk <command> output inspected

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

@TaKO8Ki
TaKO8Ki marked this pull request as draft July 27, 2026 14:31
@TaKO8Ki
TaKO8Ki marked this pull request as ready for review July 27, 2026 14:31
@TaKO8Ki
TaKO8Ki requested review from KuSh, aeppling and pszymkowiak July 27, 2026 14:32
Comment thread src/cmds/cloud/aws_cmd.rs
static ref S3_TRANSFER_RE: Regex = Regex::new(r"^(upload|download|delete|copy|move):").unwrap();
}
static S3_TRANSFER_RE: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"^(upload|download|delete|copy|move):").unwrap());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a good opportunity to replace "unwrap" with "expect.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is it better to replace all uses of unwrap with expect in this pr?

@aeppling aeppling left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some agent docs in .claude that will misslead some coding agent if used (still enforcing lazy_static)

@TaKO8Ki
TaKO8Ki force-pushed the refactor/replace-lazy-static branch from 31e9e10 to ae07b4b Compare July 27, 2026 17:20
@TaKO8Ki

TaKO8Ki commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

@aeppling I have updated the agent docs.

@TaKO8Ki
TaKO8Ki merged commit 1c5ffad into rtk-ai:develop Jul 27, 2026
11 checks passed
@TaKO8Ki
TaKO8Ki deleted the refactor/replace-lazy-static branch July 27, 2026 17:26
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Jul 27, 2026
@TaKO8Ki TaKO8Ki mentioned this pull request Jul 27, 2026
2 tasks done
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.

3 participants