@@ -13,7 +13,7 @@ use std::fs;
13
13
use std:: io:: { BufRead , BufReader , ErrorKind } ;
14
14
use std:: path:: { Path , PathBuf } ;
15
15
use std:: process:: Command ;
16
- use std:: str:: FromStr ;
16
+ use std:: str:: { from_utf8 , FromStr } ;
17
17
18
18
use toml;
19
19
@@ -678,14 +678,6 @@ edition = {}
678
678
679
679
// Create all specified source files (with respective parent directories) if they don't exist.
680
680
681
- let rustfmt_exists = match Command :: new ( "rustfmt" ) . arg ( "-V" ) . output ( ) {
682
- Ok ( _) => true ,
683
- Err ( e) => {
684
- log:: warn!( "rustfmt not found: {}" , e) ;
685
- false
686
- }
687
- } ;
688
-
689
681
for i in & opts. source_files {
690
682
let path_of_source_file = path. join ( i. relative_path . clone ( ) ) ;
691
683
@@ -718,9 +710,14 @@ mod tests {
718
710
paths:: write ( & path_of_source_file, default_file_content) ?;
719
711
720
712
// Format the newly created source file
721
- if rustfmt_exists {
722
- Command :: new ( "rustfmt" ) . arg ( & path_of_source_file) . output ( ) ?;
723
- }
713
+ match Command :: new ( "rustfmt" ) . arg ( & path_of_source_file) . output ( ) {
714
+ Err ( e) => log:: warn!( "failed to call rustfmt: {}" , e) ,
715
+ Ok ( output) => {
716
+ if !output. status . success ( ) {
717
+ log:: warn!( "rustfmt failed: {:?}" , from_utf8( & output. stdout) ) ;
718
+ }
719
+ }
720
+ } ;
724
721
}
725
722
}
726
723
0 commit comments