One Rust Borrow Error, Three Models, One Terminal
Three model runs start with one failing Cargo command
A borrow-checker error is a useful test for coding models because a confident explanation is not enough. The patch has to compile, preserve ownership semantics, and avoid quietly changing the program’s behavior. My preferred 2026 workflow is to hand the same failure to three models independently, then bring every candidate back to the terminal.
This is a repeatable comparison protocol, not a leaderboard with invented scores. For two slots, you could use Claude Sonnet 5.5 and GPT-6.1 Sol; fill the third with another available model. Keep the task identical. Three different prompts mostly measure your prompting, not the models.
E0502 needs the surrounding ownership story
Take a common cache failure: a function borrows a value through HashMap::get, inserts a missing entry, and later uses or returns the borrowed value. Depending on the control flow, rustc reports E0502 because the mutation conflicts with an immutable borrow that remains live. The important question is not “Where should I add clone?” It is “What must this function actually return?”
A returned reference, an owned value, and a shared handle imply different fixes. Give each model the function signature, relevant type definitions, complete diagnostic, and enough caller context to establish that contract. Include the Rust edition and toolchain version, especially when comparing results across machines.
- Capture the exact failing command and its complete compiler output.
- Include relevant feature flags and the smallest reproducible surrounding code.
- State whether allocations, cloning, public API changes, and unsafe are acceptable.
- Remove credentials and unrelated proprietary code before submitting the example.
The shared prompt asks for a minimal ownership repair
I would send all three models this instruction: “Explain which borrow remains live and where the conflicting access occurs. Propose the smallest behavior-preserving patch. Do not introduce unsafe, clone data, or change public signatures without explaining why. Return a patch, assumptions, and focused tests.” Attach the same source snapshot and diagnostic to each request.
Ask for a concise explanation of the ownership constraint, not an exhaustive reasoning transcript. Start each run without the other models’ answers. Otherwise, your second and third opinions become reviews of the first opinion, which is a different experiment.
Fluxo makes that terminal-side setup less fiddly: one key and one base URL, https://api.fluxorelay.com, cover these models and the wider catalog. It works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK. Keep the working directory, repository instructions, and tool permissions equivalent across runs.
HashMap::entry beats a reflexive clone when semantics fit
For the cache example, look for a candidate that considers HashMap::entry. It can combine lookup and insertion without holding a separate lookup reference across mutation. But an entry-based rewrite still deserves scrutiny: expensive value construction should remain lazy when that was the original behavior, and fallible construction needs explicit handling.
Other errors need different repairs. With E0499 around vector mutation, shortening a mutable borrow may be enough. If two distinct elements need simultaneous mutable access, split_at_mut can express their disjointness. Adding a lifetime parameter does not make overlapping exclusive borrows legal, and moving everything behind RefCell merely moves some checks to runtime.
Cargo, tests, and patch review choose the winner
Apply each candidate in a separate worktree. First rerun the original failing command. Then run relevant tests, formatting checks, and Clippy under the project’s normal configuration. A compiling patch is only the first gate.
- Test cache hits and misses without changing expected construction behavior.
- Inspect every added allocation, clone, dependency, and public signature change.
- Reject patches that silence diagnostics while weakening the intended contract.
- Record toolchain versions, model identifiers, token usage, and validation results.
Track cost alongside correctness. Fluxo bills per real token, including cache reads and writes, with no monthly fee; compare the full debugging session rather than just its first response. Users also earn a referral share when people they invite pay. If you want to try this three-run workflow, consider creating a Fluxo account.
The winning answer is the smallest understandable patch that survives your checks—not the longest explanation. Keep its regression test, record the ownership lesson, and get back to the feature you were building.