Skip to content

Commit ee064be

Browse files
author
Markus Westerlind
committed
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.
1 parent 7ac4154 commit ee064be

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/librustc_errors/json.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ impl Emitter for JsonEmitter {
104104
writeln!(&mut self.dst, "{}", as_pretty_json(&data))
105105
} else {
106106
writeln!(&mut self.dst, "{}", as_json(&data))
107-
};
107+
}
108+
.and_then(|_| self.dst.flush());
108109
if let Err(e) = result {
109110
panic!("failed to print diagnostics: {:?}", e);
110111
}
@@ -116,7 +117,8 @@ impl Emitter for JsonEmitter {
116117
writeln!(&mut self.dst, "{}", as_pretty_json(&data))
117118
} else {
118119
writeln!(&mut self.dst, "{}", as_json(&data))
119-
};
120+
}
121+
.and_then(|_| self.dst.flush());
120122
if let Err(e) = result {
121123
panic!("failed to print notification: {:?}", e);
122124
}

0 commit comments

Comments
 (0)