Skip to content

fix(coordinator): box CachedResult::Cached to fix large_enum_variant on Windows - #3001

Merged
trunk-io[bot] merged 1 commit into
mainfrom
claude/clever-wright-q4btae-coordinator-large-enum
Aug 11, 2026
Merged

trunk-io[bot] merged 1 commit into
mainfrom
claude/clever-wright-q4btae-coordinator-large-enum

Conversation

@phil-opp

@phil-opp phil-opp commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2979.

CachedResult in binaries/coordinator/src/state.rs had one large variant and one small one:

pub(crate) enum CachedResult {
    Pending { result_senders: Vec<oneshot::Sender<eyre::Result<ControlRequestReply>>> },
    Cached  { result: eyre::Result<ControlRequestReply> },  // large
}

ControlRequestReply is large, so Cached dwarfs Pending. Clippy's large_enum_variant heuristic flags this on some targets (Windows) but not others (Linux) for identical code, toolchain (1.97.1), and lockfile. Because PR CI only runs clippy on ubuntu-latest, cargo clippy --all -- -D warnings — the documented cross-platform pre-commit/pre-push gate — passed in CI yet failed for Windows contributors running the exact command the docs tell them to.

Fix

Box the result field so Cached becomes a single pointer, making the two variants comparable in size:

    Cached { result: Box<eyre::Result<ControlRequestReply>> },

The two matches! arms that destructured the field (is_terminal_error, is_cached_ok) are rewritten with .is_err() / .is_ok() guards, since box deref-patterns are unstable. All construction sites now Box::new(...) the result. send_result_to is unchanged — &Box<T> deref-coerces to &T at the call sites.

Verification

  • cargo clippy -p dora-coordinator --all-targets -- -D warnings — passes (exit 0).
  • cargo test -p dora-coordinator --lib — 110 passed; 0 failed.

Note: because the lint only fires on Windows, the fix can't be observed to remove the diagnostic on this Linux runner, but it is a strict size reduction of the flagged variant and the behavior-preserving change is covered by the existing lib tests (including the reconstruction test that asserts on CachedResult::Cached { result } if result.is_ok()).


Generated by Claude Code

…on Windows

`CachedResult::Cached` inlined a full `eyre::Result<ControlRequestReply>`,
which is large, while the sibling `Pending` variant is just a `Vec`. Clippy's
`large_enum_variant` heuristic flags this on some targets (Windows) but not
others (Linux), so `cargo clippy --all -- -D warnings` — the documented
cross-platform pre-commit/pre-push gate — passed on Linux CI yet failed for
Windows contributors on identical code, toolchain, and lockfile.

Box the `result` field so `Cached` is a single pointer, making the two
variants comparable in size. The two `matches!` arms that destructured the
field are rewritten with `.is_err()` / `.is_ok()` guards, since box
deref-patterns are unstable.

Fixes #2979

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSeehXFhKtMyFH67mSLBYt
@trunk-io

trunk-io Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

😎 Merged successfully - details.

phil-opp commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

No issues found.

Boxing CachedResult::Cached { result } to balance the enum against the Vec-sized Pending variant is a sound fix for the platform-dependent large_enum_variant clippy warning. The two matches! sites that destructured the field are correctly rewritten as .is_ok() / .is_err() guards (box deref-patterns being unstable), and Box<Result<_>> derefs transparently for those calls. The three construction sites are all updated to Box::new(...). Behavior is unchanged.


Automated review by Claude — fully automated, not vetted by a human. Treat accordingly.

Generated by Claude Code


Generated by Claude Code

GuTS805 added a commit to GuTS805/dora that referenced this pull request Aug 5, 2026
… OS-independent test

The CachedResult::Cached boxing fix duplicated the already-open PR dora-rs#3001,
so it's dropped here to avoid merge conflicts (per 'don't fix unrelated
warnings in PRs' convention).

The regression test now asserts against a hardcoded Windows-style sample
path instead of the live workspace_dir() output, since on Linux/macOS CI
the real path never contains a backslash and the old assertion passed
trivially without exercising the normalization logic.
@phil-opp
phil-opp marked this pull request as ready for review August 9, 2026 11:33
@trunk-io
trunk-io Bot merged commit e6f0267 into main Aug 11, 2026
27 checks passed
@trunk-io
trunk-io Bot deleted the claude/clever-wright-q4btae-coordinator-large-enum branch August 11, 2026 14:02
trunk-io Bot pushed a commit that referenced this pull request Aug 11, 2026
…ates (#3040)

* fix(cli): normalize workspace path to forward slashes for CMake templates
workspace_dir() returned a raw Windows path (backslash-separated),
which gets substituted verbatim into __DORA_PATH__ in the generated
CMakeLists.txt for --lang c/cxx --internal-create-with-path-dependencies.
CMake treats backslash as a string escape character, so cmake -B
failed immediately with 'Invalid character escape' before any
compiler logic ran. Normalize to forward slashes, which both CMake
and Windows accept.

Also box the large Cached variant of CachedResult in the coordinator
(pre-existing clippy::large_enum_variant failure surfaced while
running clippy locally, related to #2979).

* fix: address review feedback - drop unrelated coordinator change, use OS-independent test
The CachedResult::Cached boxing fix duplicated the already-open PR #3001,
so it's dropped here to avoid merge conflicts (per 'don't fix unrelated
warnings in PRs' convention).

The regression test now asserts against a hardcoded Windows-style sample
path instead of the live workspace_dir() output, since on Linux/macOS CI
the real path never contains a backslash and the old assertion passed
trivially without exercising the normalization logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clippy::large_enum_variant fails on Windows for CachedResult in binaries/coordinator/src/state.rs (passes on Linux CI)

2 participants