diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-08-08 14:43:27 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-08-08 14:58:52 +0000 |
| commit | 95c1c34fff6675910986c93c3fea3c03e9810f6a (patch) | |
| tree | 84010ffd97eeb6a452ecf3a36b8895a098da919b /compiler/rustc_errors | |
| parent | ae696f847dee523df6afed14468de70fc6479552 (diff) | |
| download | rust-95c1c34fff6675910986c93c3fea3c03e9810f6a.tar.gz rust-95c1c34fff6675910986c93c3fea3c03e9810f6a.zip | |
review comments
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/json.rs | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 5bd3b328cb8..9f4d9263f0f 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -48,6 +48,12 @@ pub enum HumanReadableErrorType { Short, } +impl HumanReadableErrorType { + pub fn short(&self) -> bool { + *self == HumanReadableErrorType::Short + } +} + #[derive(Clone, Copy, Debug)] struct Margin { /// The available whitespace in the left that can be consumed when centering. diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 02a0de201ed..32e59f9ab03 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -176,7 +176,7 @@ impl Emitter for JsonEmitter { } fn should_show_explain(&self) -> bool { - !matches!(self.json_rendered, HumanReadableErrorType::Short) + !self.json_rendered.short() } } @@ -356,7 +356,7 @@ impl Diagnostic { let buf = BufWriter::default(); let mut dst: Destination = Box::new(buf.clone()); - let short = matches!(je.json_rendered, HumanReadableErrorType::Short); + let short = je.json_rendered.short(); match je.color_config { ColorConfig::Always | ColorConfig::Auto => dst = Box::new(termcolor::Ansi::new(dst)), ColorConfig::Never => {} |
