@@ -681,10 +681,14 @@ impl OutputType {
681681}
682682
683683/// The type of diagnostics output to generate.
684- #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
684+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Default ) ]
685685pub enum ErrorOutputType {
686686 /// Output meant for the consumption of humans.
687- HumanReadable ( HumanReadableErrorType , ColorConfig ) ,
687+ #[ default]
688+ HumanReadable {
689+ kind : HumanReadableErrorType = HumanReadableErrorType :: Default ,
690+ color_config : ColorConfig = ColorConfig :: Auto ,
691+ } ,
688692 /// Output that's consumed by other tools such as `rustfix` or the `RLS`.
689693 Json {
690694 /// Render the JSON in a human readable way (with indents and newlines).
@@ -696,12 +700,6 @@ pub enum ErrorOutputType {
696700 } ,
697701}
698702
699- impl Default for ErrorOutputType {
700- fn default ( ) -> Self {
701- Self :: HumanReadable ( HumanReadableErrorType :: Default , ColorConfig :: Auto )
702- }
703- }
704-
705703#[ derive( Clone , Hash , Debug ) ]
706704pub enum ResolveDocLinks {
707705 /// Do not resolve doc links.
@@ -898,18 +896,13 @@ pub enum PrintKind {
898896 DeploymentTarget ,
899897}
900898
901- #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
899+ #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq , Default ) ]
902900pub struct NextSolverConfig {
903901 /// Whether the new trait solver should be enabled in coherence.
904- pub coherence : bool ,
902+ pub coherence : bool = true ,
905903 /// Whether the new trait solver should be enabled everywhere.
906904 /// This is only `true` if `coherence` is also enabled.
907- pub globally : bool ,
908- }
909- impl Default for NextSolverConfig {
910- fn default ( ) -> Self {
911- NextSolverConfig { coherence : true , globally : false }
912- }
905+ pub globally : bool = false,
913906}
914907
915908#[ derive( Clone ) ]
@@ -1825,7 +1818,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
18251818pub fn parse_error_format (
18261819 early_dcx : & mut EarlyDiagCtxt ,
18271820 matches : & getopts:: Matches ,
1828- color : ColorConfig ,
1821+ color_config : ColorConfig ,
18291822 json_color : ColorConfig ,
18301823 json_rendered : HumanReadableErrorType ,
18311824) -> ErrorOutputType {
@@ -1835,35 +1828,34 @@ pub fn parse_error_format(
18351828 // `opt_present` because the latter will panic.
18361829 let error_format = if matches. opts_present ( & [ "error-format" . to_owned ( ) ] ) {
18371830 match matches. opt_str ( "error-format" ) . as_deref ( ) {
1838- None | Some ( "human" ) => {
1839- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Default , color)
1840- }
1841- Some ( "human-annotate-rs" ) => {
1842- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: AnnotateSnippet , color)
1843- }
1831+ None | Some ( "human" ) => ErrorOutputType :: HumanReadable { color_config, .. } ,
1832+ Some ( "human-annotate-rs" ) => ErrorOutputType :: HumanReadable {
1833+ kind : HumanReadableErrorType :: AnnotateSnippet ,
1834+ color_config,
1835+ } ,
18441836 Some ( "json" ) => {
18451837 ErrorOutputType :: Json { pretty : false , json_rendered, color_config : json_color }
18461838 }
18471839 Some ( "pretty-json" ) => {
18481840 ErrorOutputType :: Json { pretty : true , json_rendered, color_config : json_color }
18491841 }
1850- Some ( "short" ) => ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Short , color) ,
1851- Some ( "human-unicode" ) => {
1852- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Unicode , color)
1842+ Some ( "short" ) => {
1843+ ErrorOutputType :: HumanReadable { kind : HumanReadableErrorType :: Short , color_config }
18531844 }
1845+ Some ( "human-unicode" ) => ErrorOutputType :: HumanReadable {
1846+ kind : HumanReadableErrorType :: Unicode ,
1847+ color_config,
1848+ } ,
18541849 Some ( arg) => {
1855- early_dcx. set_error_format ( ErrorOutputType :: HumanReadable (
1856- HumanReadableErrorType :: Default ,
1857- color,
1858- ) ) ;
1850+ early_dcx. set_error_format ( ErrorOutputType :: HumanReadable { color_config, .. } ) ;
18591851 early_dcx. early_fatal ( format ! (
18601852 "argument for `--error-format` must be `human`, `human-annotate-rs`, \
18611853 `human-unicode`, `json`, `pretty-json` or `short` (instead was `{arg}`)"
18621854 ) )
18631855 }
18641856 }
18651857 } else {
1866- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Default , color )
1858+ ErrorOutputType :: HumanReadable { color_config , .. }
18671859 } ;
18681860
18691861 match error_format {
@@ -1918,7 +1910,7 @@ fn check_error_format_stability(
19181910 }
19191911 let format = match format {
19201912 ErrorOutputType :: Json { pretty : true , .. } => "pretty-json" ,
1921- ErrorOutputType :: HumanReadable ( format , _ ) => match format {
1913+ ErrorOutputType :: HumanReadable { kind , .. } => match kind {
19221914 HumanReadableErrorType :: AnnotateSnippet => "human-annotate-rs" ,
19231915 HumanReadableErrorType :: Unicode => "human-unicode" ,
19241916 _ => return ,
0 commit comments