@@ -806,7 +806,7 @@ pub enum ErrorOutputType {
806806 /// Output meant for the consumption of humans.
807807 #[ default]
808808 HumanReadable {
809- kind : HumanReadableErrorType = HumanReadableErrorType :: Default { short : false } ,
809+ kind : HumanReadableErrorType = HumanReadableErrorType { short : false , unicode : false } ,
810810 color_config: ColorConfig = ColorConfig :: Auto ,
811811 } ,
812812 /// Output that's consumed by other tools such as `rustfix` or the `RLS`.
@@ -1965,16 +1965,8 @@ impl JsonUnusedExterns {
19651965///
19661966/// The first value returned is how to render JSON diagnostics, and the second
19671967/// is whether or not artifact notifications are enabled.
1968- pub fn parse_json (
1969- early_dcx : & EarlyDiagCtxt ,
1970- matches : & getopts:: Matches ,
1971- is_nightly_build : bool ,
1972- ) -> JsonConfig {
1973- let mut json_rendered = if is_nightly_build {
1974- HumanReadableErrorType :: AnnotateSnippet { short : false , unicode : false }
1975- } else {
1976- HumanReadableErrorType :: Default { short : false }
1977- } ;
1968+ pub fn parse_json ( early_dcx : & EarlyDiagCtxt , matches : & getopts:: Matches ) -> JsonConfig {
1969+ let mut json_rendered = HumanReadableErrorType { short : false , unicode : false } ;
19781970 let mut json_color = ColorConfig :: Never ;
19791971 let mut json_artifact_notifications = false ;
19801972 let mut json_unused_externs = JsonUnusedExterns :: No ;
@@ -1991,15 +1983,10 @@ pub fn parse_json(
19911983 for sub_option in option. split ( ',' ) {
19921984 match sub_option {
19931985 "diagnostic-short" => {
1994- json_rendered = if is_nightly_build {
1995- HumanReadableErrorType :: AnnotateSnippet { short : true , unicode : false }
1996- } else {
1997- HumanReadableErrorType :: Default { short : true }
1998- } ;
1986+ json_rendered = HumanReadableErrorType { short : true , unicode : false } ;
19991987 }
20001988 "diagnostic-unicode" => {
2001- json_rendered =
2002- HumanReadableErrorType :: AnnotateSnippet { short : false , unicode : true } ;
1989+ json_rendered = HumanReadableErrorType { short : false , unicode : true } ;
20031990 }
20041991 "diagnostic-rendered-ansi" => json_color = ColorConfig :: Always ,
20051992 "artifacts" => json_artifact_notifications = true ,
@@ -2029,13 +2016,8 @@ pub fn parse_error_format(
20292016 color_config : ColorConfig ,
20302017 json_color : ColorConfig ,
20312018 json_rendered : HumanReadableErrorType ,
2032- is_nightly_build : bool ,
20332019) -> ErrorOutputType {
2034- let default_kind = if is_nightly_build {
2035- HumanReadableErrorType :: AnnotateSnippet { short : false , unicode : false }
2036- } else {
2037- HumanReadableErrorType :: Default { short : false }
2038- } ;
2020+ let default_kind = HumanReadableErrorType { short : false , unicode : false } ;
20392021 // We need the `opts_present` check because the driver will send us Matches
20402022 // with only stable options if no unstable options are used. Since error-format
20412023 // is unstable, it will not be present. We have to use `opts_present` not
@@ -2045,26 +2027,18 @@ pub fn parse_error_format(
20452027 None | Some ( "human" ) => {
20462028 ErrorOutputType :: HumanReadable { color_config, kind : default_kind }
20472029 }
2048- Some ( "human-annotate-rs" ) => ErrorOutputType :: HumanReadable {
2049- kind : HumanReadableErrorType :: AnnotateSnippet { short : false , unicode : false } ,
2050- color_config,
2051- } ,
20522030 Some ( "json" ) => {
20532031 ErrorOutputType :: Json { pretty : false , json_rendered, color_config : json_color }
20542032 }
20552033 Some ( "pretty-json" ) => {
20562034 ErrorOutputType :: Json { pretty : true , json_rendered, color_config : json_color }
20572035 }
20582036 Some ( "short" ) => ErrorOutputType :: HumanReadable {
2059- kind : if is_nightly_build {
2060- HumanReadableErrorType :: AnnotateSnippet { short : true , unicode : false }
2061- } else {
2062- HumanReadableErrorType :: Default { short : true }
2063- } ,
2037+ kind : HumanReadableErrorType { short : true , unicode : false } ,
20642038 color_config,
20652039 } ,
20662040 Some ( "human-unicode" ) => ErrorOutputType :: HumanReadable {
2067- kind : HumanReadableErrorType :: AnnotateSnippet { short : false , unicode : true } ,
2041+ kind : HumanReadableErrorType { short : false , unicode : true } ,
20682042 color_config,
20692043 } ,
20702044 Some ( arg) => {
@@ -2073,8 +2047,8 @@ pub fn parse_error_format(
20732047 kind : default_kind,
20742048 } ) ;
20752049 early_dcx. early_fatal ( format ! (
2076- "argument for `--error-format` must be `human`, `human-annotate-rs `, \
2077- `human-unicode`, ` json`, `pretty-json` or `short` (instead was `{arg}`)"
2050+ "argument for `--error-format` must be `human`, `human-unicode `, \
2051+ `json`, `pretty-json` or `short` (instead was `{arg}`)"
20782052 ) )
20792053 }
20802054 }
@@ -2136,8 +2110,7 @@ fn check_error_format_stability(
21362110 let format = match format {
21372111 ErrorOutputType :: Json { pretty : true , .. } => "pretty-json" ,
21382112 ErrorOutputType :: HumanReadable { kind, .. } => match kind {
2139- HumanReadableErrorType :: AnnotateSnippet { unicode : false , .. } => "human-annotate-rs" ,
2140- HumanReadableErrorType :: AnnotateSnippet { unicode : true , .. } => "human-unicode" ,
2113+ HumanReadableErrorType { unicode : true , .. } => "human-unicode" ,
21412114 _ => return ,
21422115 } ,
21432116 _ => return ,
@@ -2465,16 +2438,9 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
24652438 json_timings,
24662439 json_unused_externs,
24672440 json_future_incompat,
2468- } = parse_json ( early_dcx, matches, unstable_features . is_nightly_build ( ) ) ;
2441+ } = parse_json ( early_dcx, matches) ;
24692442
2470- let error_format = parse_error_format (
2471- early_dcx,
2472- matches,
2473- color,
2474- json_color,
2475- json_rendered,
2476- unstable_features. is_nightly_build ( ) ,
2477- ) ;
2443+ let error_format = parse_error_format ( early_dcx, matches, color, json_color, json_rendered) ;
24782444
24792445 early_dcx. set_error_format ( error_format) ;
24802446
0 commit comments