build(rust): migrate crates to edition 2024 - #1308
Conversation
Update all Rust crate manifests from edition 2021 to 2024 now that the workspace toolchain is on Rust 1.96. Align treefmt rustfmt configuration with the crate edition so local formatting and flake checks use the same parser mode. Apply cargo fix, clippy --fix, and rustfmt output for edition-compatibility changes such as env var unsafe calls, expr_2021 macro fragments, let-chain collapses, and import ordering.
|
no API key found — this repo is configured to use To fix: add the key as a GitHub Actions secret (referenced from your workflow's Open repo secrets → · Configure model → · Setup docs → · Ask in Discord →
|
|
@coderabbitai review |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
💤 Files with no reviewable changes (3)
📝 WalkthroughWalkthroughUpdates workspace to Rust edition 2024, consolidates nested conditionals into let-chain guards, introduces a shared EnvVarGuard for tests, and normalizes imports, formatting, and test assertions across many crates. ChangesRust Edition 2024 + Workspace normalization
Estimated code review effort Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
@ryoppippi I have started the AI code review. It will take a few minutes to complete. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | 00f4790 | Commit Preview URL Branch Preview URL |
Jun 12 2026, 08:40 PM |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Fetch PR details
gh pr view 1308 --repo ccusage/ccusage
echo "=== PR Files Changed ==="
gh pr diff 1308 --repo ccusage/ccusageLength of output: 117545
ReviewEdition & tooling ✅
Import reordering ✅
Let-chain flattening ✅
Minor formatting ✅
No functional changes detected. The PR is ready to merge. |
ccusage
@ccusage/ccusage-darwin-arm64
@ccusage/ccusage-darwin-x64
@ccusage/ccusage-linux-arm64
@ccusage/ccusage-linux-x64
@ccusage/ccusage-win32-x64
commit: |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
There was a problem hiding this comment.
3 issues found across 100 files
Partial review: This PR has more than 50 files, so cubic reviewed the highest-priority files first. During the trial, paid plans get a higher file limit.
You can try an ultrareview to bypass the file limit, comment @cubic-dev-ai ultrareview. Learn more.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rust/crates/ccusage/src/adapter/goose/paths.rs`:
- Around line 62-69: The per-adapter static ENV_LOCK in goose::paths (used
around unsafe env::set_var and env::remove_var in EnvDirGuard and its Drop impl)
must be replaced with a single, repo-wide process lock and all places that
mutate process env (Goose paths, CLAUDE_CONFIG_DIR_LOCK in main.rs,
QWEN_DATA_DIR_LOCK, GEMINI_DATA_DIR_LOCK, KIMI_DATA_DIR_LOCK, etc.) must use
that same lock; update the goose::paths code to acquire the global lock before
calling unsafe { env::set_var(GOOSE_PATH_ROOT_ENV, dir) } in EnvDirGuard::new
and hold the lock (or release only after) so Drop::drop also acquires the same
global lock before calling unsafe { env::remove_var(GOOSE_PATH_ROOT_ENV) }, and
change other modules/tests to reference this single global symbol (e.g.,
PROCESS_ENV_LOCK) instead of their local locks so all process-wide env mutations
are serialized.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6d9f1ed7-30c7-4000-ad3e-1ffaadcf7060
📒 Files selected for processing (100)
nix/treefmt.nixrust/crates/ccusage-cli/Cargo.tomlrust/crates/ccusage-cli/src/help_codegen.rsrust/crates/ccusage-cli/src/lib.rsrust/crates/ccusage-cli/src/parser.rsrust/crates/ccusage-cli/src/tests.rsrust/crates/ccusage-terminal/Cargo.tomlrust/crates/ccusage-terminal/src/lib.rsrust/crates/ccusage-terminal/src/table.rsrust/crates/ccusage-terminal/src/title.rsrust/crates/ccusage-test-support/Cargo.tomlrust/crates/ccusage-test-support/src/lib.rsrust/crates/ccusage/Cargo.tomlrust/crates/ccusage/src/adapter/all/loader.rsrust/crates/ccusage/src/adapter/all/mod.rsrust/crates/ccusage/src/adapter/all/report.rsrust/crates/ccusage/src/adapter/all/tests.rsrust/crates/ccusage/src/adapter/all/types.rsrust/crates/ccusage/src/adapter/amp/loader.rsrust/crates/ccusage/src/adapter/amp/mod.rsrust/crates/ccusage/src/adapter/amp/parser.rsrust/crates/ccusage/src/adapter/amp/report.rsrust/crates/ccusage/src/adapter/claude/daily.rsrust/crates/ccusage/src/adapter/claude/mod.rsrust/crates/ccusage/src/adapter/claude/paths.rsrust/crates/ccusage/src/adapter/codebuff/loader.rsrust/crates/ccusage/src/adapter/codebuff/mod.rsrust/crates/ccusage/src/adapter/codebuff/parser.rsrust/crates/ccusage/src/adapter/codebuff/paths.rsrust/crates/ccusage/src/adapter/codebuff/report.rsrust/crates/ccusage/src/adapter/codex/aggregate.rsrust/crates/ccusage/src/adapter/codex/loader.rsrust/crates/ccusage/src/adapter/codex/mod.rsrust/crates/ccusage/src/adapter/codex/parser.rsrust/crates/ccusage/src/adapter/codex/paths.rsrust/crates/ccusage/src/adapter/codex/report.rsrust/crates/ccusage/src/adapter/copilot/loader.rsrust/crates/ccusage/src/adapter/copilot/mod.rsrust/crates/ccusage/src/adapter/copilot/parser.rsrust/crates/ccusage/src/adapter/copilot/paths.rsrust/crates/ccusage/src/adapter/copilot/report.rsrust/crates/ccusage/src/adapter/droid/loader.rsrust/crates/ccusage/src/adapter/droid/mod.rsrust/crates/ccusage/src/adapter/droid/parser.rsrust/crates/ccusage/src/adapter/droid/paths.rsrust/crates/ccusage/src/adapter/droid/report.rsrust/crates/ccusage/src/adapter/gemini/loader.rsrust/crates/ccusage/src/adapter/gemini/mod.rsrust/crates/ccusage/src/adapter/gemini/parser.rsrust/crates/ccusage/src/adapter/gemini/paths.rsrust/crates/ccusage/src/adapter/gemini/report.rsrust/crates/ccusage/src/adapter/goose/loader.rsrust/crates/ccusage/src/adapter/goose/mod.rsrust/crates/ccusage/src/adapter/goose/parser.rsrust/crates/ccusage/src/adapter/goose/paths.rsrust/crates/ccusage/src/adapter/goose/report.rsrust/crates/ccusage/src/adapter/hermes/loader.rsrust/crates/ccusage/src/adapter/hermes/mod.rsrust/crates/ccusage/src/adapter/hermes/parser.rsrust/crates/ccusage/src/adapter/hermes/report.rsrust/crates/ccusage/src/adapter/kilo/loader.rsrust/crates/ccusage/src/adapter/kilo/mod.rsrust/crates/ccusage/src/adapter/kilo/parser.rsrust/crates/ccusage/src/adapter/kilo/report.rsrust/crates/ccusage/src/adapter/kimi/loader.rsrust/crates/ccusage/src/adapter/kimi/mod.rsrust/crates/ccusage/src/adapter/kimi/parser.rsrust/crates/ccusage/src/adapter/kimi/paths.rsrust/crates/ccusage/src/adapter/kimi/report.rsrust/crates/ccusage/src/adapter/openclaw/loader.rsrust/crates/ccusage/src/adapter/openclaw/mod.rsrust/crates/ccusage/src/adapter/openclaw/parser.rsrust/crates/ccusage/src/adapter/openclaw/paths.rsrust/crates/ccusage/src/adapter/openclaw/report.rsrust/crates/ccusage/src/adapter/opencode/loader.rsrust/crates/ccusage/src/adapter/opencode/mod.rsrust/crates/ccusage/src/adapter/opencode/parser.rsrust/crates/ccusage/src/adapter/opencode/report.rsrust/crates/ccusage/src/adapter/pi/loader.rsrust/crates/ccusage/src/adapter/pi/mod.rsrust/crates/ccusage/src/adapter/pi/parser.rsrust/crates/ccusage/src/adapter/pi/paths.rsrust/crates/ccusage/src/adapter/pi/report.rsrust/crates/ccusage/src/adapter/qwen/loader.rsrust/crates/ccusage/src/adapter/qwen/mod.rsrust/crates/ccusage/src/adapter/qwen/parser.rsrust/crates/ccusage/src/adapter/qwen/paths.rsrust/crates/ccusage/src/adapter/qwen/report.rsrust/crates/ccusage/src/blocks.rsrust/crates/ccusage/src/cli.rsrust/crates/ccusage/src/commands/mod.rsrust/crates/ccusage/src/config.rsrust/crates/ccusage/src/config_schema.rsrust/crates/ccusage/src/cost.rsrust/crates/ccusage/src/date_utils.rsrust/crates/ccusage/src/main.rsrust/crates/ccusage/src/output.rsrust/crates/ccusage/src/pricing.rsrust/crates/ccusage/src/progress.rsrust/crates/ccusage/src/summary.rs
Add a shared test-support environment variable guard that holds a single process-wide mutex while temporarily setting environment variables. Replace module-local locks and direct unsafe env mutations in tests with the shared RAII guard so Rust 2024 unsafe environment access is isolated in one audited helper and restored consistently.
|
@coderabbitai review Addressed the environment mutation review feedback in 00f4790 by centralizing temporary env var mutation behind a shared test-support RAII guard with one process-wide mutex. Local validation: cargo test --manifest-path rust/Cargo.toml --workspace; nix flake check --print-build-logs. |
@ryoppippi I have started the AI code review. It will take a few minutes to complete. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
There was a problem hiding this comment.
No issues found across 100 files
Partial review: This PR has more than 50 files, so cubic reviewed the highest-priority files first. During the trial, paid plans get a higher file limit.
You can try an ultrareview to bypass the file limit, comment @cubic-dev-ai ultrareview. Learn more.
Re-trigger cubic
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |

Summary
Notes
Validation
Need help on this PR? Tag
/codesmithwith what you need. Autofix is enabled.Summary by cubic
Migrate all Rust crates to edition 2024 and align formatting. No functional changes; adopts 2024 syntax/safety rules and centralizes test env-var handling.
edition = "2024"in all crates and updatedtreefmtrustfmtedition to 2024.cargo fix,clippy --fix, andrustfmtfor 2024 patterns (let-chains, import ordering).EnvVarGuard(process-wide mutex + RAII), replacing ad-hoc locks and direct mutations.Written for commit 00f4790. Summary will update on new commits.
Summary by CodeRabbit