Skip to content

fix(cargo): pass short-format build, check, clippy and test output through - #5102

Open
KuSh wants to merge 1 commit into
rtk-ai:developfrom
KuSh:fix/cargo-d3-short
Open

KuSh wants to merge 1 commit into
rtk-ai:developfrom
KuSh:fix/cargo-d3-short

Conversation

@KuSh

@KuSh KuSh commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

With --message-format=short, cargo prints each diagnostic as path:line:col: warning: …, starting with the path, and the build/check and clippy filters only read lines starting with warning: or error. A build with warnings reported a clean build, one with errors printed only the exit code, clippy reported No issues found for a run with warnings and for one that failed, and a short-format cargo test with compile errors kept only its last lines.

The short format is already one line per diagnostic, which the user asked cargo for. When it is in effect, rtk cargo build, check, clippy and test now run cargo unfiltered, through the passthrough rtk cargo uses for subcommands it has no filter for.

Behaviour changes

  • The format is read in one place, through the argument tokenizer, the way cargo 1.98 reads it: every --message-format before --, values split on ,, ASCII case ignored, json-* values refining a JSON format.
  • Two formats, or the same one twice, are refused by cargo before it builds anything; those runs pass through and show cargo's error. The previous "last occurrence wins" rule did not match cargo.
  • --message-format=JSON (upper case) now reaches the JSON filter, and a --message-format after -- (the test binary's or clippy-driver's) no longer routes cargo's output.
  • A passing short-format cargo test loses its one-line summary; it prints what cargo printed.
  • Known limit: cargo replays the cached warnings of a crate it does not rebuild in the format they were first printed in, so a run without the flag right after a short-format one can still print short warnings, which the human filter does not read, as before.

Test plan

  • cargo fmt --all, cargo clippy --all-targets, cargo test --all --no-fail-fast (5,929 passed)
  • Unit tests for the format rules, each value syntax checked against real cargo 1.98.1 under LC_ALL=C
  • End-to-end test through the binary with a cargo shim: short and rejected formats match cargo stream for stream with its exit code, the human format and a format after -- are still filtered
  • Real runs on probe crates (warnings, errors, multi-line workspace warnings, build scripts, unknown lint): short-format runs match raw cargo; human and JSON runs match develop

Fixes #5064

🤖 Generated with Claude Code

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working cargo rust labels Nov 13, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

Fixes rtk's cargo output filters for build, check, clippy, and test so that --message-format=short runs pass through to raw cargo output instead of being misparsed by filters expecting human/json formats. The PR centralizes message-format detection via a new argument tokenizer that matches cargo 1.98's own parsing rules (handles -- separators, comma-split values, case-insensitivity, duplicate/conflicting format rejection).

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #5064


Analyzed automatically by wshm · This is an automated analysis, not a human review.

…rough

`--message-format=short` prints a diagnostic as `path:line:col: warning: …`, starting
with the path, and the build/check handler and the clippy filter only read lines starting
with `warning:` or `error`. A build with warnings reported a clean build, one with errors
printed only the exit code, and clippy reported `No issues found` for a run with warnings
and for one that failed. `cargo test` showed the last five lines of a short-format compile
failure, dropping the diagnostics before them.

The short format is already one line per diagnostic, which the user asked cargo for. When
it is in effect, `rtk cargo build`, `check`, `clippy` and `test` now run cargo unfiltered,
through the passthrough `rtk cargo` uses for a subcommand it has no filter for: inherited
stdout and stderr and cargo's exit code. The human and JSON formats are filtered as
before.

The format is read from the arguments. Cargo replays the cached warnings of a crate it
does not rebuild in the format they were first printed in, so a run without the flag
after a short-format one can still print short warnings, which the human filter does not
read, as on develop.

The format in effect is read in one place, through the argument tokenizer, the way cargo
reads it: every `--message-format` before `--`, each value split on `,`, ASCII case
ignored. `human`, `short` and `json` set the format, and `json-diagnostic-short`,
`json-diagnostic-rendered-ansi` and `json-render-diagnostics` refine a JSON one. A later
occurrence does not win: cargo refuses two formats, or the same one twice
(`--message-format=json --message-format=human`), before it builds anything, so those runs
pass through as well and show cargo's own error. This replaces the last-occurrence rule the
JSON routing used.

Fixes rtk-ai#5064

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cargo rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk cargo build --message-format=short reports a clean build and drops the warnings

1 participant