Rollup merge of #128806 - estebank:color-config, r=jieyouxu

Split `ColorConfig` off of `HumanReadableErrorType`

The previous setup tied two unrelated things together. Splitting these two is a better model.

Identified by https://github.com/rust-lang/rust/pull/126597/files#r1667800754
This commit is contained in:
Matthias Krüger
2024-08-09 00:03:36 +02:00
committed by GitHub
9 changed files with 64 additions and 50 deletions

View File

@@ -43,19 +43,14 @@ const DEFAULT_COLUMN_WIDTH: usize = 140;
/// Describes the way the content of the `rendered` field of the json output is generated
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HumanReadableErrorType {
Default(ColorConfig),
AnnotateSnippet(ColorConfig),
Short(ColorConfig),
Default,
AnnotateSnippet,
Short,
}
impl HumanReadableErrorType {
/// Returns a (`short`, `color`) tuple
pub fn unzip(self) -> (bool, ColorConfig) {
match self {
HumanReadableErrorType::Default(cc) => (false, cc),
HumanReadableErrorType::Short(cc) => (true, cc),
HumanReadableErrorType::AnnotateSnippet(cc) => (false, cc),
}
pub fn short(&self) -> bool {
*self == HumanReadableErrorType::Short
}
}