config_macros.rs: try rustfmt on generated module
parent
0169025d50
commit
f8cef3290e
|
@ -153,33 +153,42 @@ use super::*;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
let rustfmt_closure = move |output_file: &mut File, output_string: &str| {
|
||||||
let mut rustfmt = Command::new("rustfmt")
|
let mut rustfmt = Command::new("rustfmt")
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("failed to execute rustfmt");
|
.map_err(|err| format!("failed to execute rustfmt {}", err))?;
|
||||||
|
|
||||||
{
|
{
|
||||||
// limited borrow of stdin
|
// limited borrow of stdin
|
||||||
let stdin = rustfmt
|
let stdin = rustfmt
|
||||||
.stdin
|
.stdin
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.expect("failed to get rustfmt stdin");
|
.ok_or("failed to get rustfmt stdin")?;
|
||||||
stdin
|
stdin
|
||||||
.write_all(output_string.as_bytes())
|
.write_all(output_string.as_bytes())
|
||||||
.expect("failed to write to rustfmit stdin");
|
.map_err(|err| format!("failed to write to rustfmt stdin {}", err))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = rustfmt
|
||||||
|
.wait_with_output()
|
||||||
|
.map_err(|err| format!("failed to wait on rustfmt child {}", err))?;
|
||||||
|
if !output.stderr.is_empty() {
|
||||||
|
return Err(format!(
|
||||||
|
"rustfmt invocation replied with: `{}`",
|
||||||
|
String::from_utf8_lossy(&output.stderr)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
output_file
|
||||||
|
.write_all(&output.stdout)
|
||||||
|
.expect("failed to write to src/conf/overrides.rs");
|
||||||
|
Ok(())
|
||||||
|
};
|
||||||
|
if let Err(err) = rustfmt_closure(&mut output_file, &output_string) {
|
||||||
|
println!("Tried rustfmt on overrides module, got error: {}", err);
|
||||||
|
output_file.write_all(output_string.as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = rustfmt
|
|
||||||
.wait_with_output()
|
|
||||||
.expect("failed to wait on rustfmt child");
|
|
||||||
if !output.stderr.is_empty() {
|
|
||||||
panic!(format!("{}", String::from_utf8_lossy(&output.stderr)));
|
|
||||||
}
|
|
||||||
|
|
||||||
output_file.write_all(&output.stdout).unwrap();
|
|
||||||
*/
|
|
||||||
output_file.write_all(output_string.as_bytes()).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue