@@ -655,10 +655,14 @@ impl OutputType {
655655}
656656
657657/// The type of diagnostics output to generate.
658- #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
658+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Default ) ]
659659pub enum ErrorOutputType {
660660 /// 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+ } ,
662666 /// Output that's consumed by other tools such as `rustfix` or the `RLS`.
663667 Json {
664668 /// Render the JSON in a human readable way (with indents and newlines).
@@ -670,12 +674,6 @@ pub enum ErrorOutputType {
670674 } ,
671675}
672676
673- impl Default for ErrorOutputType {
674- fn default ( ) -> Self {
675- Self :: HumanReadable ( HumanReadableErrorType :: Default , ColorConfig :: Auto )
676- }
677- }
678-
679677#[ derive( Clone , Hash , Debug ) ]
680678pub enum ResolveDocLinks {
681679 /// Do not resolve doc links.
@@ -1790,7 +1788,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
17901788pub fn parse_error_format (
17911789 early_dcx : & mut EarlyDiagCtxt ,
17921790 matches : & getopts:: Matches ,
1793- color : ColorConfig ,
1791+ color_config : ColorConfig ,
17941792 json_color : ColorConfig ,
17951793 json_rendered : HumanReadableErrorType ,
17961794) -> ErrorOutputType {
@@ -1800,35 +1798,34 @@ pub fn parse_error_format(
18001798 // `opt_present` because the latter will panic.
18011799 let error_format = if matches. opts_present ( & [ "error-format" . to_owned ( ) ] ) {
18021800 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+ } ,
18091806 Some ( "json" ) => {
18101807 ErrorOutputType :: Json { pretty : false , json_rendered, color_config : json_color }
18111808 }
18121809 Some ( "pretty-json" ) => {
18131810 ErrorOutputType :: Json { pretty : true , json_rendered, color_config : json_color }
18141811 }
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 }
18181814 }
1815+ Some ( "human-unicode" ) => ErrorOutputType :: HumanReadable {
1816+ kind : HumanReadableErrorType :: Unicode ,
1817+ color_config,
1818+ } ,
18191819 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, .. } ) ;
18241821 early_dcx. early_fatal ( format ! (
18251822 "argument for `--error-format` must be `human`, `human-annotate-rs`, \
18261823 `human-unicode`, `json`, `pretty-json` or `short` (instead was `{arg}`)"
18271824 ) )
18281825 }
18291826 }
18301827 } else {
1831- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Default , color )
1828+ ErrorOutputType :: HumanReadable { color_config , .. }
18321829 } ;
18331830
18341831 match error_format {
@@ -1883,7 +1880,7 @@ fn check_error_format_stability(
18831880 }
18841881 let format = match format {
18851882 ErrorOutputType :: Json { pretty : true , .. } => "pretty-json" ,
1886- ErrorOutputType :: HumanReadable ( format , _ ) => match format {
1883+ ErrorOutputType :: HumanReadable { kind , .. } => match kind {
18871884 HumanReadableErrorType :: AnnotateSnippet => "human-annotate-rs" ,
18881885 HumanReadableErrorType :: Unicode => "human-unicode" ,
18891886 _ => return ,
0 commit comments