diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-07-26 18:24:14 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-07-31 09:34:36 +0000 |
| commit | 826a8ef52ed7809953e5a702d5ea88de2f1fd065 (patch) | |
| tree | ea1540784cfa818b78af1078b12049af54c7a9be /compiler/rustc_errors/src | |
| parent | 1e2167f5b56b443c70546bcd332c87266c1def29 (diff) | |
| download | rust-826a8ef52ed7809953e5a702d5ea88de2f1fd065.tar.gz rust-826a8ef52ed7809953e5a702d5ea88de2f1fd065.zip | |
Remove a now-redundant single-variant enum
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 48 |
1 files 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<usize> { - 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. |
