Skip to content

--check does not exit with status code 1 when input file is stdin #5376

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

Open
Colecf opened this issue Jun 9, 2022 · 0 comments
Open

--check does not exit with status code 1 when input file is stdin #5376

Colecf opened this issue Jun 9, 2022 · 0 comments

Comments

@Colecf
Copy link

Colecf commented Jun 9, 2022

--check doe not exit with status code 1 if the input file is stdin, despite what --help says.

Honestly, this behavior is preferable for our usecase, as we can already tell if the input is formatted correctly by the presence of the output diff, and can use the status code for more fatal errors.

$ rustfmt --version
rustfmt 1.4.38-stable (fe5b13d 2022-05-18)
$ rustfmt --help
...
        --check         Run in 'check' mode. Exits with 0 if input is
                        formatted correctly. Exits with 1 and prints a diff if
                        formatting is required.
...
$ rustfmt --check < server.rs
Diff in <stdin> at line 12:
 impl Drop for Server {
     fn drop(&mut self) {
         if !thread::panicking() {
-                self.handle.take().unwrap().join().unwrap();
+            self.handle.take().unwrap().join().unwrap();
         }
     }
 }
$ echo $?
0
$ rustfmt --check server.rs
Diff in /ssd/aosp-master/external/rust/crates/openssl/openssl/src/ssl/test/server.rs at line 12:
 impl Drop for Server {
     fn drop(&mut self) {
         if !thread::panicking() {
-                self.handle.take().unwrap().join().unwrap();
+            self.handle.take().unwrap().join().unwrap();
         }
     }
 }
$ echo $?
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants