about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-07-26 18:39:10 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-07-31 09:34:36 +0000
commit2131eee179019bb0572b17943e4913ff77108123 (patch)
tree7bd088772966f4038075701a061092c815ba9999
parent10da30f540f76c10c7f029da1eec27439496f703 (diff)
downloadrust-2131eee179019bb0572b17943e4913ff77108123.tar.gz
rust-2131eee179019bb0572b17943e4913ff77108123.zip
Turn a single-variant enum into a struct
-rw-r--r--compiler/rustc_errors/src/emitter.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index b51ec3a8fcd..2d1b954690e 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -7,8 +7,6 @@
 //!
 //! The output types are defined in `rustc_session::config::ErrorOutputType`.
 
-use Destination::*;
-
 use rustc_span::source_map::SourceMap;
 use rustc_span::{FileLines, SourceFile, Span};
 
@@ -675,7 +673,7 @@ impl EmitterWriter {
         dst: Box<dyn WriteColor + Send>,
         fallback_bundle: LazyFallbackBundle,
     ) -> EmitterWriter {
-        Self::create(Raw(dst), fallback_bundle)
+        Self::create(Destination(dst), fallback_bundle)
     }
 
     fn maybe_anonymized(&self, line_num: usize) -> Cow<'static, str> {
@@ -2603,9 +2601,7 @@ fn emit_to_destination(
     Ok(())
 }
 
-pub enum Destination {
-    Raw(Box<(dyn WriteColor + Send)>),
-}
+pub struct Destination(pub(crate) Box<(dyn WriteColor + Send)>);
 
 struct Buffy {
     buffer_writer: BufferWriter,
@@ -2648,24 +2644,20 @@ impl Destination {
         // On non-Windows we rely on the atomicity of `write` to ensure errors
         // don't get all jumbled up.
         if cfg!(windows) {
-            Raw(Box::new(StandardStream::stderr(choice)))
+            Destination(Box::new(StandardStream::stderr(choice)))
         } else {
             let buffer_writer = BufferWriter::stderr(choice);
             let buffer = buffer_writer.buffer();
-            Raw(Box::new(Buffy { buffer_writer, buffer }))
+            Destination(Box::new(Buffy { buffer_writer, buffer }))
         }
     }
 
     fn writable(&mut self) -> &mut dyn WriteColor {
-        match *self {
-            Destination::Raw(ref mut t) => t,
-        }
+        &mut self.0
     }
 
     fn supports_color(&self) -> bool {
-        match *self {
-            Self::Raw(ref writer) => writer.supports_color(),
-        }
+        self.0.supports_color()
     }
 }