refactor(binary): rewrite pre-2018 ref-patterns to match ergonomics - #91
Merged
jhamill34 merged 1 commit intoAug 26, 2026
Merged
Conversation
This was referenced Aug 26, 2026
Closes #85 (Phase 2 of #1). Converts every &Variant(ref x)-style site in apicli and apid to plain match-ergonomics form -- purely syntactic, binds the identical reference type as before, with one exception handled explicitly: apicli/template.rs's Integer(key) arm bound key: &i64 via ergonomics where the original &InputTokens::Integer(key) explicit-deref pattern bound an owned (Copy) i64 -- fixed by dereferencing at the use site instead of changing the match arm. apid/main.rs's provide_input handler matches Some((_, tx)) against a &mut-sourced get_mut() call; ergonomics binds tx: &mut Sender where the original ref tx bound &Sender, but Sender::send only needs &self so this is behaviorally inert. apicli's path.rs and stub.rs account for most of this PR's sites (30 of 33) and weren't flagged by clippy::ref_patterns/match_ref_pats/ needless_borrowed_reference at all -- those lints don't reliably fire on every &Some(Variant(_))-shaped match arm mixed with `ref`-bound arms in the same match. Found instead via the original manual site inventory from #1's scoping research; worth noting since a future clippy-only search of this codebase would miss them. apicli/engine.rs's merge() function keeps its outer `match &left`/ `match &right` (left/right are owned Schema values reused later in the same arms via `one_of.push(left)`/`vec![left, right]`, so the scrutinee itself can't drop its `&` without moving out from under later use) -- only the arm patterns lost their redundant `&`/`ref`. apicli/template.rs also fixes the impl ToString for PathKey match's ref-pattern shape only, not the ToString/Display issue itself (#13). Confirmed via a full `cargo clippy --workspace --all-features`: zero ref_patterns/match_ref_pats/needless_borrowed_reference warnings remain anywhere in the workspace, closing out issue #85. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VzKriyNnMHmqQ6UxPhsv2
jhamill34
force-pushed
the
claude/issue-1-phase2-binaries
branch
from
August 26, 2026 23:50
46ee4e0 to
99cd11d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #85 (Phase 2 of #1). Stacked on #90 (
runners/*), which is stacked on #89 (usecases/*), which is stacked on #88 (Phase 1's lint policy).Same transform as #89/#90, applied to
binary/apicliandbinary/apid:if let &Some(ref x) = &y { ... }→if let Some(x) = &y { ... }match &value { &Variant(ref x) => ..., ... }→match value { Variant(x) => ..., ... }Crates touched:
apicli(33 sites acrossengine.rs,path.rs,stub.rs,template.rs),apid(1 site).Two sites needed care beyond the mechanical transform:
template.rs'sInteger(key)arm: the original explicit-deref pattern bound an ownedi64(the payload isCopy); plain ergonomics would have silently changed the binding to&i64instead. Fixed by dereferencing at the use site so the type stays identical.apid/main.rs'sprovide_input: matches against a&mut-sourcedget_mut()call. Ergonomics binds the tuple's second field as&mut Senderwhere the original bound&Sender— confirmed inert sinceSender::sendonly needs&self.Worth flagging for anyone auditing this style of cleanup in the future: 30 of
apicli's 33 sites (all ofpath.rsandstub.rs) were not flagged byclippy::ref_patterns/match_ref_pats/needless_borrowed_referenceat all — those lints don't reliably fire on&Some(Variant(_))-shaped match arms mixed with_/ref-bound arms in the same match. They were only caught by cross-checking against the manual site inventory from #1's original scoping research, not from clippy's live output.engine.rs'smerge()function also intentionally keeps itsmatch &left/match &rightscrutinee un-simplified (only the arm patterns lost their&/ref) sinceleft/rightare owned values reused later in the same arms.Confirmed via a full workspace clippy run: zero
ref_patterns/match_ref_pats/needless_borrowed_referencewarnings remain anywhere in the repo after this PR — closes out #85 completely.Test plan
cargo build -p apicli -p apid --all-features— clean.cargo clippy -p apicli -p apid --all-features— zero warnings from the three targeted lints.cargo test -p apicli -p apid --all-features— 15 tests, 0 failures (includingtemplate::test::test_parse_starts_with_index, which exercises theInteger(key)Copy-type fix).cargo clippy --workspace --all-features— zeroref_patterns/match_ref_pats/needless_borrowed_referencewarnings workspace-wide.cargo build --workspace --all-features/cargo test --workspace --all-features— clean, zero failures.cargo fmt --all -- --check— clean.Generated by Claude Code