Skip to content

Commit 204ee2b

Browse files
committed
formatting
1 parent 5f30890 commit 204ee2b

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/main.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use std::ffi::{OsStr, OsString};
5151
use std::io::BufRead;
5252
use std::io::Write;
5353
use std::path::{Path, PathBuf};
54-
use std::process::{Command, Output};
54+
use std::process::{Command, Output, Stdio};
5555
use std::sync::atomic::{AtomicUsize, Ordering};
5656
use std::sync::{Arc, Mutex};
5757
use std::time::Instant;
@@ -2692,12 +2692,33 @@ fn analyze() {
26922692

26932693
let output = trd.output().unwrap();
26942694
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();
26952716

26962717
let analysis = Analysis {
26972718
ice: ice.clone(),
2698-
mvce: reduced_file,
2719+
mvce: reduced_fmt_file,
26992720
};
2700-
2721+
eprintln!("---------------------------formatted:");
27012722
eprintln!("{}", analysis.mvce);
27022723
}
27032724
})

0 commit comments

Comments
 (0)