From f5639a66e67c8900247c4c48ad9c7c31916e9ffd Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 12 Sep 2017 16:35:45 -0700 Subject: [PATCH] Flush stdout before writing to stderr. In particular, terminal.reset() doesn't flush, so it ensures that stderr isn't unintentionally printed in the color of the preceding line. --- cranelift/src/cton-util.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cranelift/src/cton-util.rs b/cranelift/src/cton-util.rs index a7ad8a44b4..e702f57ae4 100644 --- a/cranelift/src/cton-util.rs +++ b/cranelift/src/cton-util.rs @@ -98,6 +98,7 @@ fn main() { if !msg.ends_with('\n') { msg.push('\n'); } + io::stdout().flush().expect("flushing stdout"); io::stderr().write_all(msg.as_bytes()).unwrap(); process::exit(1); }