@@ -655,10 +655,14 @@ impl OutputType {
655
655
}
656
656
657
657
/// The type of diagnostics output to generate.
658
- #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
658
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Default ) ]
659
659
pub enum ErrorOutputType {
660
660
/// Output meant for the consumption of humans.
661
- HumanReadable ( HumanReadableErrorType , ColorConfig ) ,
661
+ #[ default]
662
+ HumanReadable {
663
+ kind : HumanReadableErrorType = HumanReadableErrorType :: Default ,
664
+ color_config : ColorConfig = ColorConfig :: Auto ,
665
+ } ,
662
666
/// Output that's consumed by other tools such as `rustfix` or the `RLS`.
663
667
Json {
664
668
/// Render the JSON in a human readable way (with indents and newlines).
@@ -670,12 +674,6 @@ pub enum ErrorOutputType {
670
674
} ,
671
675
}
672
676
673
- impl Default for ErrorOutputType {
674
- fn default ( ) -> Self {
675
- Self :: HumanReadable ( HumanReadableErrorType :: Default , ColorConfig :: Auto )
676
- }
677
- }
678
-
679
677
#[ derive( Clone , Hash , Debug ) ]
680
678
pub enum ResolveDocLinks {
681
679
/// Do not resolve doc links.
@@ -1790,7 +1788,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
1790
1788
pub fn parse_error_format (
1791
1789
early_dcx : & mut EarlyDiagCtxt ,
1792
1790
matches : & getopts:: Matches ,
1793
- color : ColorConfig ,
1791
+ color_config : ColorConfig ,
1794
1792
json_color : ColorConfig ,
1795
1793
json_rendered : HumanReadableErrorType ,
1796
1794
) -> ErrorOutputType {
@@ -1800,35 +1798,34 @@ pub fn parse_error_format(
1800
1798
// `opt_present` because the latter will panic.
1801
1799
let error_format = if matches. opts_present ( & [ "error-format" . to_owned ( ) ] ) {
1802
1800
match matches. opt_str ( "error-format" ) . as_deref ( ) {
1803
- None | Some ( "human" ) => {
1804
- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Default , color)
1805
- }
1806
- Some ( "human-annotate-rs" ) => {
1807
- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: AnnotateSnippet , color)
1808
- }
1801
+ None | Some ( "human" ) => ErrorOutputType :: HumanReadable { color_config, .. } ,
1802
+ Some ( "human-annotate-rs" ) => ErrorOutputType :: HumanReadable {
1803
+ kind : HumanReadableErrorType :: AnnotateSnippet ,
1804
+ color_config,
1805
+ } ,
1809
1806
Some ( "json" ) => {
1810
1807
ErrorOutputType :: Json { pretty : false , json_rendered, color_config : json_color }
1811
1808
}
1812
1809
Some ( "pretty-json" ) => {
1813
1810
ErrorOutputType :: Json { pretty : true , json_rendered, color_config : json_color }
1814
1811
}
1815
- Some ( "short" ) => ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Short , color) ,
1816
- Some ( "human-unicode" ) => {
1817
- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Unicode , color)
1812
+ Some ( "short" ) => {
1813
+ ErrorOutputType :: HumanReadable { kind : HumanReadableErrorType :: Short , color_config }
1818
1814
}
1815
+ Some ( "human-unicode" ) => ErrorOutputType :: HumanReadable {
1816
+ kind : HumanReadableErrorType :: Unicode ,
1817
+ color_config,
1818
+ } ,
1819
1819
Some ( arg) => {
1820
- early_dcx. set_error_format ( ErrorOutputType :: HumanReadable (
1821
- HumanReadableErrorType :: Default ,
1822
- color,
1823
- ) ) ;
1820
+ early_dcx. set_error_format ( ErrorOutputType :: HumanReadable { color_config, .. } ) ;
1824
1821
early_dcx. early_fatal ( format ! (
1825
1822
"argument for `--error-format` must be `human`, `human-annotate-rs`, \
1826
1823
`human-unicode`, `json`, `pretty-json` or `short` (instead was `{arg}`)"
1827
1824
) )
1828
1825
}
1829
1826
}
1830
1827
} else {
1831
- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Default , color )
1828
+ ErrorOutputType :: HumanReadable { color_config , .. }
1832
1829
} ;
1833
1830
1834
1831
match error_format {
@@ -1883,7 +1880,7 @@ fn check_error_format_stability(
1883
1880
}
1884
1881
let format = match format {
1885
1882
ErrorOutputType :: Json { pretty : true , .. } => "pretty-json" ,
1886
- ErrorOutputType :: HumanReadable ( format , _ ) => match format {
1883
+ ErrorOutputType :: HumanReadable { kind , .. } => match kind {
1887
1884
HumanReadableErrorType :: AnnotateSnippet => "human-annotate-rs" ,
1888
1885
HumanReadableErrorType :: Unicode => "human-unicode" ,
1889
1886
_ => return ,
0 commit comments