rustfmt: `--check` silently ignored when formatting from stdin

When I run,

echo '
fn   foo (   ) {
    fake_fn("this is fine");
    fake_fn   ( "This not so much"    )    ;
}
' | rustfmt --check

the output is equivalent to rustfmt --emit stdout. Ideally, I would like to see the above call emit something like,

Diff in 'stdin' at line 1:
-fn   foo (   ) {
+fn foo() {
     fake_fn("this is fine");
-    fake_fn   ( "This not so much"    )    ;
+    fake_fn("This not so much");
 }

If that’s not possible, a warning or error message noting the ignored option would make this behavior less surprising, and may help nudge users towards valid usage.

It might also be worth noting that rustfmt +nightly --emit json is silently ignored in the same situations.

$ rustfmt --version
rustfmt 1.4.4-stable (0462008d 2019-08-06)
$ rustfmt +nightly --version
rustfmt 1.4.9-nightly (33e36670 2019-10-07)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (18 by maintainers)

Most upvoted comments

I’d be interested in working on this - making it an error as a first step, and then looking into making --check and --emit work.