From ee064befa06ad54193786c9169672f9349d0bfaf Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Mon, 17 Feb 2020 16:46:51 +0100 Subject: [PATCH] Ensure diagnostics are printed in the correct order Even when buffered. Ideally we would flush only when the emitter is done, but that requires larger changes. This gives most of the benefit of buffering in any case. --- src/librustc_errors/json.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustc_errors/json.rs b/src/librustc_errors/json.rs index f0cfd815a2c..97b9ca924bb 100644 --- a/src/librustc_errors/json.rs +++ b/src/librustc_errors/json.rs @@ -104,7 +104,8 @@ fn emit_diagnostic(&mut self, diag: &crate::Diagnostic) { writeln!(&mut self.dst, "{}", as_pretty_json(&data)) } else { writeln!(&mut self.dst, "{}", as_json(&data)) - }; + } + .and_then(|_| self.dst.flush()); if let Err(e) = result { panic!("failed to print diagnostics: {:?}", e); } @@ -116,7 +117,8 @@ fn emit_artifact_notification(&mut self, path: &Path, artifact_type: &str) { writeln!(&mut self.dst, "{}", as_pretty_json(&data)) } else { writeln!(&mut self.dst, "{}", as_json(&data)) - }; + } + .and_then(|_| self.dst.flush()); if let Err(e) = result { panic!("failed to print notification: {:?}", e); } -- 2.44.0