From 826a8ef52ed7809953e5a702d5ea88de2f1fd065 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 26 Jul 2023 18:24:14 +0000 Subject: [PATCH] Remove a now-redundant single-variant enum --- compiler/rustc_errors/src/emitter.rs | 48 +++------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 13d405c41bc..cf456ebc8d5 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -2158,7 +2158,7 @@ impl EmitterWriter { Err(e) => panic!("failed to emit error: {e}"), } - let mut dst = self.dst.writable(); + let dst = self.dst.writable(); match writeln!(dst) { Err(e) => panic!("failed to emit error: {e}"), _ => { @@ -2573,7 +2573,7 @@ fn emit_to_destination( ) -> io::Result<()> { use crate::lock; - let mut dst = dst.writable(); + let dst = dst.writable(); // In order to prevent error message interleaving, where multiple error lines get intermixed // when multiple compiler processes error simultaneously, we emit errors with additional @@ -2608,10 +2608,6 @@ pub enum Destination { Raw(Box<(dyn WriteColor + Send)>), } -pub enum WritableDst<'a> { - Raw(&'a mut (dyn WriteColor + Send)), -} - struct Buffy { buffer_writer: BufferWriter, buffer: Buffer, @@ -2661,10 +2657,10 @@ impl Destination { } } - fn writable(&mut self) -> WritableDst<'_> { + fn writable(&mut self) -> &mut dyn WriteColor { match *self { - Destination::Terminal(ref mut t) => WritableDst::Raw(t), - Destination::Raw(ref mut t) => WritableDst::Raw(t), + Destination::Terminal(ref mut t) => t, + Destination::Raw(ref mut t) => t, } } @@ -2728,40 +2724,6 @@ impl Style { } } -impl<'a> WritableDst<'a> { - fn set_color(&mut self, color: &ColorSpec) -> io::Result<()> { - match *self { - WritableDst::Raw(ref mut t) => t.set_color(color), - } - } - - fn reset(&mut self) -> io::Result<()> { - match *self { - WritableDst::Raw(ref mut t) => t.reset(), - } - } -} - -impl<'a> Write for WritableDst<'a> { - fn write(&mut self, bytes: &[u8]) -> io::Result { - match *self { - WritableDst::Raw(ref mut w) => w.write(bytes), - } - } - - fn flush(&mut self) -> io::Result<()> { - match *self { - WritableDst::Raw(ref mut w) => w.flush(), - } - } -} - -impl<'a> Drop for WritableDst<'a> { - fn drop(&mut self) { - self.flush().unwrap() - } -} - /// Whether the original and suggested code are visually similar enough to warrant extra wording. pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool { // FIXME: this should probably be extended to also account for `FO0` → `FOO` and unicode.