]> git.lizzy.rs Git - rust.git/commitdiff
Ensure diagnostics are printed in the correct order
authorMarkus Westerlind <markus.westerlind@distilnetworks.com>
Mon, 17 Feb 2020 15:46:51 +0000 (16:46 +0100)
committerMarkus Westerlind <markus.westerlind@distilnetworks.com>
Mon, 17 Feb 2020 15:46:53 +0000 (16:46 +0100)
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

index f0cfd815a2c3e473f1e127ac08f322745eae39cf..97b9ca924bb7c9460bf4c6703776c8fdf9eca33d 100644 (file)
@@ -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);
         }