From 375d8f1b25b12d252e6aff030c0bcf64b77f886b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 26 Jul 2023 18:52:08 +0000 Subject: Sanity check that we actually flush all buffers --- compiler/rustc_errors/src/emitter.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compiler/rustc_errors/src') diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 0d73073395b..0cae06881b1 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -2617,6 +2617,15 @@ impl Write for Buffy { } } +impl Drop for Buffy { + fn drop(&mut self) { + if !self.buffer.is_empty() { + self.flush().unwrap(); + panic!("buffers need to be flushed in order to print their contents"); + } + } +} + impl WriteColor for Buffy { fn supports_color(&self) -> bool { self.buffer.supports_color() -- cgit 1.4.1-3-g733a5