about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/json.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-08-08 01:46:16 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-08-08 14:41:33 +0000
commitae696f847dee523df6afed14468de70fc6479552 (patch)
tree29bb0bb8d3374df1da2a70c90c6279f58712c353 /compiler/rustc_errors/src/json.rs
parentce20e15f01a9dcc4543e8d52b4b281df6c4dbb8e (diff)
downloadrust-ae696f847dee523df6afed14468de70fc6479552.tar.gz
rust-ae696f847dee523df6afed14468de70fc6479552.zip
Split `ColorConfig` off of `HumanReadableErrorType`
The previous setup tied two unrelated things together. Splitting these two is a better model.
Diffstat (limited to 'compiler/rustc_errors/src/json.rs')
-rw-r--r--compiler/rustc_errors/src/json.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs
index 42a28bc7890..02a0de201ed 100644
--- a/compiler/rustc_errors/src/json.rs
+++ b/compiler/rustc_errors/src/json.rs
@@ -55,6 +55,7 @@ pub struct JsonEmitter {
     ignored_directories_in_source_blocks: Vec<String>,
     #[setters(skip)]
     json_rendered: HumanReadableErrorType,
+    color_config: ColorConfig,
     diagnostic_width: Option<usize>,
     macro_backtrace: bool,
     track_diagnostics: bool,
@@ -68,6 +69,7 @@ impl JsonEmitter {
         fallback_bundle: LazyFallbackBundle,
         pretty: bool,
         json_rendered: HumanReadableErrorType,
+        color_config: ColorConfig,
     ) -> JsonEmitter {
         JsonEmitter {
             dst: IntoDynSyncSend(dst),
@@ -79,6 +81,7 @@ impl JsonEmitter {
             ui_testing: false,
             ignored_directories_in_source_blocks: Vec::new(),
             json_rendered,
+            color_config,
             diagnostic_width: None,
             macro_backtrace: false,
             track_diagnostics: false,
@@ -173,7 +176,7 @@ impl Emitter for JsonEmitter {
     }
 
     fn should_show_explain(&self) -> bool {
-        !matches!(self.json_rendered, HumanReadableErrorType::Short(_))
+        !matches!(self.json_rendered, HumanReadableErrorType::Short)
     }
 }
 
@@ -353,8 +356,8 @@ impl Diagnostic {
 
         let buf = BufWriter::default();
         let mut dst: Destination = Box::new(buf.clone());
-        let (short, color_config) = je.json_rendered.unzip();
-        match color_config {
+        let short = matches!(je.json_rendered, HumanReadableErrorType::Short);
+        match je.color_config {
             ColorConfig::Always | ColorConfig::Auto => dst = Box::new(termcolor::Ansi::new(dst)),
             ColorConfig::Never => {}
         }