Include rustfmt's stderr in errors returned from `rustfmt` function. PiperOrigin-RevId: 427455092
diff --git a/rs_bindings_from_cc/token_stream_printer.rs b/rs_bindings_from_cc/token_stream_printer.rs index bec091a..37b1ce2 100644 --- a/rs_bindings_from_cc/token_stream_printer.rs +++ b/rs_bindings_from_cc/token_stream_printer.rs
@@ -87,6 +87,7 @@ ]) .stdin(Stdio::piped()) .stdout(Stdio::piped()) + .stderr(Stdio::piped()) .spawn() .unwrap_or_else(|_| panic!("Failed to spawn rustfmt at '{}'", rustfmt)); @@ -97,8 +98,7 @@ let output = child.wait_with_output().expect("Failed to read rustfmt stdout"); if !output.status.success() { - // The rustfmt error message has already been printed to stderr. - bail!("Unable to format output with rustfmt"); + bail!("rustfmt reported an error: {}", String::from_utf8_lossy(&output.stderr)); } Ok(String::from_utf8_lossy(&output.stdout).to_string())