Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error_on_unformatted doesn't actually make cargo fmt exit with non-zero #6023

Open
Veetaha opened this issue Jan 12, 2024 · 1 comment
Open

Comments

@Veetaha
Copy link

Veetaha commented Jan 12, 2024

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: #3392

@AaronKutch
Copy link

I ran into this same issue, a temporary workaround is to check if the stderr is non-empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants