Remove a bool for color in favor of the WriteColor trait wrapping colored and uncolored printing

This commit is contained in:
Oli Scherer
2023-07-26 13:58:50 +00:00
parent 0e7ec9683d
commit 51c22154f5
7 changed files with 49 additions and 25 deletions

View File

@@ -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