@@ -681,10 +681,14 @@ impl OutputType {
681
681
}
682
682
683
683
/// The type of diagnostics output to generate.
684
- #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
684
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Default ) ]
685
685
pub enum ErrorOutputType {
686
686
/// 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
+ } ,
688
692
/// Output that's consumed by other tools such as `rustfix` or the `RLS`.
689
693
Json {
690
694
/// Render the JSON in a human readable way (with indents and newlines).
@@ -696,12 +700,6 @@ pub enum ErrorOutputType {
696
700
} ,
697
701
}
698
702
699
- impl Default for ErrorOutputType {
700
- fn default ( ) -> Self {
701
- Self :: HumanReadable ( HumanReadableErrorType :: Default , ColorConfig :: Auto )
702
- }
703
- }
704
-
705
703
#[ derive( Clone , Hash , Debug ) ]
706
704
pub enum ResolveDocLinks {
707
705
/// Do not resolve doc links.
@@ -898,18 +896,13 @@ pub enum PrintKind {
898
896
DeploymentTarget ,
899
897
}
900
898
901
- #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
899
+ #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq , Default ) ]
902
900
pub struct NextSolverConfig {
903
901
/// Whether the new trait solver should be enabled in coherence.
904
- pub coherence : bool ,
902
+ pub coherence : bool = true ,
905
903
/// Whether the new trait solver should be enabled everywhere.
906
904
/// 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,
913
906
}
914
907
915
908
#[ derive( Clone ) ]
@@ -1825,7 +1818,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
1825
1818
pub fn parse_error_format (
1826
1819
early_dcx : & mut EarlyDiagCtxt ,
1827
1820
matches : & getopts:: Matches ,
1828
- color : ColorConfig ,
1821
+ color_config : ColorConfig ,
1829
1822
json_color : ColorConfig ,
1830
1823
json_rendered : HumanReadableErrorType ,
1831
1824
) -> ErrorOutputType {
@@ -1835,35 +1828,34 @@ pub fn parse_error_format(
1835
1828
// `opt_present` because the latter will panic.
1836
1829
let error_format = if matches. opts_present ( & [ "error-format" . to_owned ( ) ] ) {
1837
1830
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
+ } ,
1844
1836
Some ( "json" ) => {
1845
1837
ErrorOutputType :: Json { pretty : false , json_rendered, color_config : json_color }
1846
1838
}
1847
1839
Some ( "pretty-json" ) => {
1848
1840
ErrorOutputType :: Json { pretty : true , json_rendered, color_config : json_color }
1849
1841
}
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 }
1853
1844
}
1845
+ Some ( "human-unicode" ) => ErrorOutputType :: HumanReadable {
1846
+ kind : HumanReadableErrorType :: Unicode ,
1847
+ color_config,
1848
+ } ,
1854
1849
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, .. } ) ;
1859
1851
early_dcx. early_fatal ( format ! (
1860
1852
"argument for `--error-format` must be `human`, `human-annotate-rs`, \
1861
1853
`human-unicode`, `json`, `pretty-json` or `short` (instead was `{arg}`)"
1862
1854
) )
1863
1855
}
1864
1856
}
1865
1857
} else {
1866
- ErrorOutputType :: HumanReadable ( HumanReadableErrorType :: Default , color )
1858
+ ErrorOutputType :: HumanReadable { color_config , .. }
1867
1859
} ;
1868
1860
1869
1861
match error_format {
@@ -1918,7 +1910,7 @@ fn check_error_format_stability(
1918
1910
}
1919
1911
let format = match format {
1920
1912
ErrorOutputType :: Json { pretty : true , .. } => "pretty-json" ,
1921
- ErrorOutputType :: HumanReadable ( format , _ ) => match format {
1913
+ ErrorOutputType :: HumanReadable { kind , .. } => match kind {
1922
1914
HumanReadableErrorType :: AnnotateSnippet => "human-annotate-rs" ,
1923
1915
HumanReadableErrorType :: Unicode => "human-unicode" ,
1924
1916
_ => return ,
0 commit comments