Skip to content

Use std::sync::LazyLock instead of once_cell::Lazy - #1014

Merged
mulkieran merged 1 commit into
stratis-storage:masterfrom
mulkieran:issue_project_833
Dec 10, 2025
Merged

mulkieran merged 1 commit into
stratis-storage:masterfrom
mulkieran:issue_project_833

Conversation

@mulkieran

@mulkieran mulkieran commented Dec 10, 2025 •

Copy link
Copy Markdown
Member

Generally better to use the library standard facility rather than an
external crate where possible.

LazyLock was introduced in version 1.80.0 of the Rust standard library.

Signed-off-by: mulhern <amulhern@redhat.com>
@mulkieran mulkieran added this to the devicemapper-v0.34.6 milestone Dec 10, 2025
@mulkieran mulkieran self-assigned this Dec 10, 2025
@coderabbitai

coderabbitai Bot commented Dec 10, 2025 •

Copy link
Copy Markdown

Walkthrough

The codebase migrates from the external once_cell crate to Rust's standard library LazyLock, removing the external dependency and updating two lazy-initialized static declarations to use the stdlib equivalent.

Changes

Cohort / File(s) Summary
Dependency removal
Cargo.toml
Removed once_cell = "1.19.0" dependency from [dependencies] section
LazyLock migration
src/core/dm_ioctl.rs, src/core/dm_udev_sync.rs
Replaced once_cell::sync::Lazy with std::sync::LazyLock for two static declarations (IOCTL_VERSIONS and SYSV_SEM_SUPPORTED); updated imports accordingly

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Homogeneous, mechanical refactoring across all changes
  • Straightforward type substitution with no logic modifications
  • Limited scope (3 files) with consistent pattern
  • No behavioral changes to verify

Poem

🐰 Once_cell, once_cell, we bid you goodbye,
LazyLock from stdlib now catches our eye,
Dependencies fewer, the code runs so clean,
Rust's standard treasure, the best we have seen! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly and accurately describes the main change: replacing once_cell::Lazy with std::sync::LazyLock across multiple files, which aligns with the file-level summaries.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3649845 and f23d3fc.

📒 Files selected for processing (3)
  • Cargo.toml (0 hunks)
  • src/core/dm_ioctl.rs (2 hunks)
  • src/core/dm_udev_sync.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
  • GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
  • GitHub Check: checks (clippy, 1.91.0, make -f Makefile clippy)
  • GitHub Check: yamllint
  • GitHub Check: tests-with-sudo (1.91.0)
🔇 Additional comments (2)
src/core/dm_udev_sync.rs (1)

40-40: LazyLock migration for SYSV_SEM_SUPPORTED looks correct; confirm MSRV alignment

The switch from once_cell::sync::Lazy<bool> to std::sync::LazyLock<bool> plus LazyLock::new(sysv_sem_supported) is behaviorally equivalent here (same lazy, thread‑safe boolean initialization, and *SYSV_SEM_SUPPORTED continues to work via Deref). I don’t see any semantic or concurrency regressions around the use in the begin path.

The one thing to double‑check is that the crate’s documented MSRV (and CI toolchain) is new enough to include std::sync::LazyLock; if you publish an explicit MSRV, it may be worth mentioning this bump in the changelog/release notes if it changes.

Also applies to: 64-64

src/core/dm_ioctl.rs (1)

6-6: IOCTL_VERSIONS LazyLock conversion is sound and verified

The change to use std::sync::LazyLock from the standard library is correct. The MSRV is set to Rust 1.82.0, which exceeds the minimum required version for LazyLock (1.80.0), and there are no remaining once_cell references in the codebase. The lazy, thread-safe initialization behavior and the ioctl_to_version logic are preserved as expected.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mulkieran mulkieran moved this to In Review in 2025December Dec 10, 2025
@packit-as-a-service

Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo dnf install -y 'dnf*-command(copr)'
  • dnf copr enable packit/stratis-storage-devicemapper-rs-1014
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

1 similar comment
@packit-as-a-service

Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo dnf install -y 'dnf*-command(copr)'
  • dnf copr enable packit/stratis-storage-devicemapper-rs-1014
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@mulkieran
mulkieran merged commit dc2db38 into stratis-storage:master Dec 10, 2025
15 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in 2025December Dec 10, 2025
@mulkieran
mulkieran deleted the issue_project_833 branch December 10, 2025 22:53
@mulkieran mulkieran moved this from Done to Done(1) in 2025December Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done(1)

Development

Successfully merging this pull request may close these issues.

1 participant