`error_on_unformatted` doesn't actually make cargo fmt exit with non-zero
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I tried this command in my repo.
$ cargo fmt --all -- --check --config unstable_features=true --config error_on_unformatted=true
error[internal]: not formatted because a comment would be lost
--> /home/path/redacted/mod.rs:55
|
92 | match rp.kind {
|
= note: set `error_on_unformatted = false` to suppress the warning against comments or string literals
warning: rustfmt has failed to format. See previous 1 errors.
I expected the command to exit with a non-zero status code to make sure it fails on CI, but it didn't. I suppose it's because the error[internal] is not actually an error, but a warning or smth like a non-failing error? I think this is a bug.
Versions
This behavior reproduces both on stable 1.74.0 and on nightly:
$cargo +nightly fmt --version
rustfmt 1.7.0-nightly (190f4c9 2024-01-09)
$ cargo +nightly --version
cargo 1.77.0-nightly (2ce45605d 2024-01-04)
References
Tracking issue reference: https://github.com/rust-lang/rustfmt/issues/3392
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the exact cargo fmt --all -- --check --config unstable_features=true --config error_on_unformatted=true command using the reported stable or nightly versions. Trace how rustfmt reports the error_on_unformatted diagnostic and how cargo fmt determines its exit status. Done means the command exits non-zero for this condition, with regression coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100