@@ -51,7 +51,7 @@ use std::ffi::{OsStr, OsString};
51
51
use std:: io:: BufRead ;
52
52
use std:: io:: Write ;
53
53
use std:: path:: { Path , PathBuf } ;
54
- use std:: process:: { Command , Output } ;
54
+ use std:: process:: { Command , Output , Stdio } ;
55
55
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
56
56
use std:: sync:: { Arc , Mutex } ;
57
57
use std:: time:: Instant ;
@@ -2692,12 +2692,33 @@ fn analyze() {
2692
2692
2693
2693
let output = trd. output ( ) . unwrap ( ) ;
2694
2694
let reduced_file = String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) ;
2695
+ eprintln ! ( "---------------------------reduced" ) ;
2696
+ eprintln ! ( "{reduced_file}" ) ;
2697
+
2698
+ eprintln ! ( "---------------------------" ) ;
2699
+
2700
+ // find possible edition flags inside the rustcflags which we will also need to pass to rustfmt?
2701
+ let mut fmt = std:: process:: Command :: new ( "rustfmt" )
2702
+ . stdin ( Stdio :: piped ( ) )
2703
+ . stdout ( Stdio :: piped ( ) )
2704
+ . spawn ( )
2705
+ . expect ( "Failed to spawn rustfnt process" ) ;
2706
+
2707
+ let mut stdin = fmt. stdin . take ( ) . expect ( "Failed to open stdin" ) ;
2708
+ std:: thread:: spawn ( move || {
2709
+ stdin
2710
+ . write_all ( reduced_file. as_bytes ( ) )
2711
+ . expect ( "Failed to write to stdin" ) ;
2712
+ } ) ;
2713
+
2714
+ let output = fmt. wait_with_output ( ) . expect ( "Failed to read stdout" ) ;
2715
+ let reduced_fmt_file = String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) ;
2695
2716
2696
2717
let analysis = Analysis {
2697
2718
ice : ice. clone ( ) ,
2698
- mvce : reduced_file ,
2719
+ mvce : reduced_fmt_file ,
2699
2720
} ;
2700
-
2721
+ eprintln ! ( "---------------------------formatted:" ) ;
2701
2722
eprintln ! ( "{}" , analysis. mvce) ;
2702
2723
}
2703
2724
} )
0 commit comments