about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-07-26 14:58:04 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-07-31 09:34:36 +0000
commit1e2167f5b56b443c70546bcd332c87266c1def29 (patch)
tree24807d1bfd62d7c5f1f8cbda0d1760ee91d0374b
parent00074698a7addd9bc726e3742c6462d2ee9627bf (diff)
downloadrust-1e2167f5b56b443c70546bcd332c87266c1def29.tar.gz
rust-1e2167f5b56b443c70546bcd332c87266c1def29.zip
Move `WritableDst` method onto `Style` directly
-rw-r--r--compiler/rustc_errors/src/emitter.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index d60d4c7c8fb..13d405c41bc 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -2590,7 +2590,8 @@ fn emit_to_destination(
     let _buffer_lock = lock::acquire_global_lock("rustc_errors");
     for (pos, line) in rendered_buffer.iter().enumerate() {
         for part in line {
-            dst.apply_style(*lvl, part.style)?;
+            let style = part.style.color_spec(*lvl);
+            dst.set_color(&style)?;
             write!(dst, "{}", part.text)?;
             dst.reset()?;
         }
@@ -2675,10 +2676,10 @@ impl Destination {
     }
 }
 
-impl<'a> WritableDst<'a> {
-    fn apply_style(&mut self, lvl: Level, style: Style) -> io::Result<()> {
+impl Style {
+    fn color_spec(&self, lvl: Level) -> ColorSpec {
         let mut spec = ColorSpec::new();
-        match style {
+        match self {
             Style::Addition => {
                 spec.set_fg(Some(Color::Green)).set_intense(true);
             }
@@ -2723,9 +2724,11 @@ impl<'a> WritableDst<'a> {
                 spec.set_bold(true);
             }
         }
-        self.set_color(&spec)
+        spec
     }
+}
 
+impl<'a> WritableDst<'a> {
     fn set_color(&mut self, color: &ColorSpec) -> io::Result<()> {
         match *self {
             WritableDst::Raw(ref mut t) => t.set_color(color),