Skip to content

Commit 2131eee

Browse files
committed
Turn a single-variant enum into a struct
1 parent 10da30f commit 2131eee

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

Diff for: compiler/rustc_errors/src/emitter.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//!
88
//! The output types are defined in `rustc_session::config::ErrorOutputType`.
99
10-
use Destination::*;
11-
1210
use rustc_span::source_map::SourceMap;
1311
use rustc_span::{FileLines, SourceFile, Span};
1412

@@ -675,7 +673,7 @@ impl EmitterWriter {
675673
dst: Box<dyn WriteColor + Send>,
676674
fallback_bundle: LazyFallbackBundle,
677675
) -> EmitterWriter {
678-
Self::create(Raw(dst), fallback_bundle)
676+
Self::create(Destination(dst), fallback_bundle)
679677
}
680678

681679
fn maybe_anonymized(&self, line_num: usize) -> Cow<'static, str> {
@@ -2603,9 +2601,7 @@ fn emit_to_destination(
26032601
Ok(())
26042602
}
26052603

2606-
pub enum Destination {
2607-
Raw(Box<(dyn WriteColor + Send)>),
2608-
}
2604+
pub struct Destination(pub(crate) Box<(dyn WriteColor + Send)>);
26092605

26102606
struct Buffy {
26112607
buffer_writer: BufferWriter,
@@ -2648,24 +2644,20 @@ impl Destination {
26482644
// On non-Windows we rely on the atomicity of `write` to ensure errors
26492645
// don't get all jumbled up.
26502646
if cfg!(windows) {
2651-
Raw(Box::new(StandardStream::stderr(choice)))
2647+
Destination(Box::new(StandardStream::stderr(choice)))
26522648
} else {
26532649
let buffer_writer = BufferWriter::stderr(choice);
26542650
let buffer = buffer_writer.buffer();
2655-
Raw(Box::new(Buffy { buffer_writer, buffer }))
2651+
Destination(Box::new(Buffy { buffer_writer, buffer }))
26562652
}
26572653
}
26582654

26592655
fn writable(&mut self) -> &mut dyn WriteColor {
2660-
match *self {
2661-
Destination::Raw(ref mut t) => t,
2662-
}
2656+
&mut self.0
26632657
}
26642658

26652659
fn supports_color(&self) -> bool {
2666-
match *self {
2667-
Self::Raw(ref writer) => writer.supports_color(),
2668-
}
2660+
self.0.supports_color()
26692661
}
26702662
}
26712663

0 commit comments

Comments
 (0)