about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/json.rs
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-07-26 13:58:50 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-07-31 09:34:36 +0000
commit51c22154f56d54d512b0b14aebf9eb18278963a1 (patch)
tree0778ba91c5f56e4f4675dbca0c88b37f9609a5b3 /compiler/rustc_errors/src/json.rs
parent0e7ec9683dae0a0bc66797b1351059ed642f4e2d (diff)
downloadrust-51c22154f56d54d512b0b14aebf9eb18278963a1.tar.gz
rust-51c22154f56d54d512b0b14aebf9eb18278963a1.zip
Remove a `bool` for color in favor of the `WriteColor` trait wrapping colored and uncolored printing
Diffstat (limited to 'compiler/rustc_errors/src/json.rs')
-rw-r--r--compiler/rustc_errors/src/json.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs
index e199244b1e4..b8f58e3057c 100644
--- a/compiler/rustc_errors/src/json.rs
+++ b/compiler/rustc_errors/src/json.rs
@@ -10,6 +10,7 @@
 // FIXME: spec the JSON output properly.
 
 use rustc_span::source_map::{FilePathMapping, SourceMap};
+use termcolor::{ColorSpec, WriteColor};
 
 use crate::emitter::{Emitter, HumanReadableErrorType};
 use crate::registry::Registry;
@@ -356,6 +357,19 @@ impl Diagnostic {
                 self.0.lock().unwrap().flush()
             }
         }
+        impl WriteColor for BufWriter {
+            fn supports_color(&self) -> bool {
+                false
+            }
+
+            fn set_color(&mut self, _spec: &ColorSpec) -> io::Result<()> {
+                Ok(())
+            }
+
+            fn reset(&mut self) -> io::Result<()> {
+                Ok(())
+            }
+        }
         let buf = BufWriter::default();
         let output = buf.clone();
         je.json_rendered