Allow compilation without rustfmt installed
When rustfmt isn't installed (or at least not in the path) throw a
warning rather then failing compilation. This make it the same severity
as rustfmt exiting with an error.
@@ -18,7 +18,14 @@ fn main() {
rustfmt.arg("--emit").arg("files").arg(&dest_path);
- let fmt_result = rustfmt.status().expect("Failed to run rustfmt");
+ let fmt_result = match rustfmt.status() {
+ Ok(o) => o,
+ Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
+ println!("cargo:warning=Failed to format generated target file. rustfmt not found",);
+ return;
+ }
+ Err(e) => panic!("Failed to run rustfmt: {:?}", e),
+ };
if !fmt_result.success() {
println!("cargo:warning=Failed to format generated target file.",);
