@@ -72,13 +72,13 @@ pub enum OutputType {
72
72
73
73
#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
74
74
pub enum ErrorOutputType {
75
- Tty ( ColorConfig ) ,
75
+ HumanReadable ( ColorConfig ) ,
76
76
Json ,
77
77
}
78
78
79
79
impl Default for ErrorOutputType {
80
80
fn default ( ) -> ErrorOutputType {
81
- ErrorOutputType :: Tty ( ColorConfig :: Auto )
81
+ ErrorOutputType :: HumanReadable ( ColorConfig :: Auto )
82
82
}
83
83
}
84
84
@@ -135,7 +135,7 @@ pub struct Options {
135
135
pub test : bool ,
136
136
pub parse_only : bool ,
137
137
pub no_trans : bool ,
138
- pub output : ErrorOutputType ,
138
+ pub error_format : ErrorOutputType ,
139
139
pub treat_err_as_bug : bool ,
140
140
pub incremental_compilation : bool ,
141
141
pub dump_dep_graph : bool ,
@@ -252,12 +252,7 @@ pub fn basic_options() -> Options {
252
252
debugging_opts : basic_debugging_options ( ) ,
253
253
prints : Vec :: new ( ) ,
254
254
cg : basic_codegen_options ( ) ,
255
- <<<<<<< HEAD
256
- color: ColorConfig :: Auto ,
257
- =======
258
- output: ErrorOutputType :: default ( ) ,
259
- show_span : None ,
260
- >>>>>>> Add an --output option for specifying an error emitter
255
+ error_format : ErrorOutputType :: default ( ) ,
261
256
externs : HashMap :: new ( ) ,
262
257
crate_name : None ,
263
258
alt_std_name : None ,
@@ -324,7 +319,7 @@ macro_rules! options {
324
319
$struct_name { $( $opt: $init) ,* }
325
320
}
326
321
327
- pub fn $buildfn( matches: & getopts:: Matches , output : ErrorOutputType ) -> $struct_name
322
+ pub fn $buildfn( matches: & getopts:: Matches , error_format : ErrorOutputType ) -> $struct_name
328
323
{
329
324
let mut op = $defaultfn( ) ;
330
325
for option in matches. opt_strs( $prefix) {
@@ -338,20 +333,20 @@ macro_rules! options {
338
333
if !setter( & mut op, value) {
339
334
match ( value, opt_type_desc) {
340
335
( Some ( ..) , None ) => {
341
- early_error( output , & format!( "{} option `{}` takes no \
342
- value", $outputname, key) )
336
+ early_error( error_format , & format!( "{} option `{}` takes no \
337
+ value", $outputname, key) )
343
338
}
344
339
( None , Some ( type_desc) ) => {
345
- early_error( output , & format!( "{0} option `{1}` requires \
346
- {2} ({3} {1}=<value>)",
347
- $outputname, key,
348
- type_desc, $prefix) )
340
+ early_error( error_format , & format!( "{0} option `{1}` requires \
341
+ {2} ({3} {1}=<value>)",
342
+ $outputname, key,
343
+ type_desc, $prefix) )
349
344
}
350
345
( Some ( value) , Some ( type_desc) ) => {
351
- early_error( output , & format!( "incorrect value `{}` for {} \
352
- option `{}` - {} was expected",
353
- value, $outputname,
354
- key, type_desc) )
346
+ early_error( error_format , & format!( "incorrect value `{}` for {} \
347
+ option `{}` - {} was expected",
348
+ value, $outputname,
349
+ key, type_desc) )
355
350
}
356
351
( None , None ) => unreachable!( )
357
352
}
@@ -360,8 +355,8 @@ macro_rules! options {
360
355
break ;
361
356
}
362
357
if !found {
363
- early_error( output , & format!( "unknown {} option: `{}`" ,
364
- $outputname, key) ) ;
358
+ early_error( error_format , & format!( "unknown {} option: `{}`" ,
359
+ $outputname, key) ) ;
365
360
}
366
361
}
367
362
return op;
@@ -879,7 +874,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
879
874
"NAME=PATH" ) ,
880
875
opt:: opt ( "" , "sysroot" , "Override the system root" , "PATH" ) ,
881
876
opt:: multi ( "Z" , "" , "Set internal debugging options" , "FLAG" ) ,
882
- opt:: opt_u( "" , "output " , "How errors and other mesasges are produced" , "tty |json" ) ,
877
+ opt:: opt_u ( "" , "error-format " , "How errors and other messages are produced" , "human |json" ) ,
883
878
opt:: opt ( "" , "color" , "Configure coloring of output:
884
879
auto = colorize, if output goes to a tty (default);
885
880
always = always colorize output;
@@ -929,19 +924,20 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
929
924
} ;
930
925
931
926
// We need the opts_present check because the driver will send us Matches
932
- // with only stable options if no unstable options are used. Since output is
933
- // unstable, it will not be present. We have to use opts_present not
927
+ // with only stable options if no unstable options are used. Since error-format
928
+ // is unstable, it will not be present. We have to use opts_present not
934
929
// opt_present because the latter will panic.
935
- let output = if matches. opts_present( & [ "output " . to_owned( ) ] ) {
936
- match matches. opt_str( "output " ) . as_ref( ) . map( |s| & s[ ..] ) {
937
- Some ( "tty " ) => ErrorOutputType :: Tty ( color) ,
930
+ let error_format = if matches. opts_present ( & [ "error-format " . to_owned ( ) ] ) {
931
+ match matches. opt_str ( "error-format " ) . as_ref ( ) . map ( |s| & s[ ..] ) {
932
+ Some ( "human " ) => ErrorOutputType :: HumanReadable ( color) ,
938
933
Some ( "json" ) => ErrorOutputType :: Json ,
939
934
940
935
None => ErrorOutputType :: default ( ) ,
941
936
942
937
Some ( arg) => {
943
- early_error( ErrorOutputType :: default ( ) , & format!( "argument for --output must be \
944
- tty or json (instead was `{}`)",
938
+ early_error ( ErrorOutputType :: default ( ) , & format ! ( "argument for --error-format must \
939
+ be human or json (instead was \
940
+ `{}`)",
945
941
arg) )
946
942
}
947
943
}
@@ -951,7 +947,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
951
947
952
948
let unparsed_crate_types = matches. opt_strs ( "crate-type" ) ;
953
949
let crate_types = parse_crate_types_from_list ( unparsed_crate_types)
954
- . unwrap_or_else( |e| early_error( output , & e[ ..] ) ) ;
950
+ . unwrap_or_else ( |e| early_error ( error_format , & e[ ..] ) ) ;
955
951
956
952
let mut lint_opts = vec ! ( ) ;
957
953
let mut describe_lints = false ;
@@ -968,11 +964,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
968
964
969
965
let lint_cap = matches. opt_str ( "cap-lints" ) . map ( |cap| {
970
966
lint:: Level :: from_str ( & cap) . unwrap_or_else ( || {
971
- early_error( output , & format!( "unknown lint level: `{}`" , cap) )
967
+ early_error ( error_format , & format ! ( "unknown lint level: `{}`" , cap) )
972
968
} )
973
969
} ) ;
974
970
975
- let debugging_opts = build_debugging_options( matches, output ) ;
971
+ let debugging_opts = build_debugging_options ( matches, error_format ) ;
976
972
977
973
let parse_only = debugging_opts. parse_only ;
978
974
let no_trans = debugging_opts. no_trans ;
@@ -998,7 +994,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
998
994
"link" => OutputType :: Exe ,
999
995
"dep-info" => OutputType :: DepInfo ,
1000
996
part => {
1001
- early_error( output , & format!( "unknown emission type: `{}`" ,
997
+ early_error ( error_format , & format ! ( "unknown emission type: `{}`" ,
1002
998
part) )
1003
999
}
1004
1000
} ;
@@ -1011,7 +1007,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1011
1007
output_types. insert ( OutputType :: Exe , None ) ;
1012
1008
}
1013
1009
1014
- let mut cg = build_codegen_options( matches, output ) ;
1010
+ let mut cg = build_codegen_options ( matches, error_format ) ;
1015
1011
1016
1012
// Issue #30063: if user requests llvm-related output to one
1017
1013
// particular path, disable codegen-units.
@@ -1023,11 +1019,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1023
1019
} ) . collect ( ) ;
1024
1020
if !incompatible. is_empty ( ) {
1025
1021
for ot in & incompatible {
1026
- early_warn( output , & format!( "--emit={} with -o incompatible with \
1027
- -C codegen-units=N for N > 1",
1028
- ot. shorthand( ) ) ) ;
1022
+ early_warn ( error_format , & format ! ( "--emit={} with -o incompatible with \
1023
+ -C codegen-units=N for N > 1",
1024
+ ot. shorthand( ) ) ) ;
1029
1025
}
1030
- early_warn( output , "resetting to default -C codegen-units=1" ) ;
1026
+ early_warn ( error_format , "resetting to default -C codegen-units=1" ) ;
1031
1027
cg. codegen_units = 1 ;
1032
1028
}
1033
1029
}
@@ -1040,7 +1036,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1040
1036
let opt_level = {
1041
1037
if matches. opt_present ( "O" ) {
1042
1038
if cg. opt_level . is_some ( ) {
1043
- early_error( output , "-O and -C opt-level both provided" ) ;
1039
+ early_error ( error_format , "-O and -C opt-level both provided" ) ;
1044
1040
}
1045
1041
OptLevel :: Default
1046
1042
} else {
@@ -1051,9 +1047,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1051
1047
Some ( 2 ) => OptLevel :: Default ,
1052
1048
Some ( 3 ) => OptLevel :: Aggressive ,
1053
1049
Some ( arg) => {
1054
- early_error( output , & format!( "optimization level needs to be \
1055
- between 0-3 (instead was `{}`)",
1056
- arg) ) ;
1050
+ early_error ( error_format , & format ! ( "optimization level needs to be \
1051
+ between 0-3 (instead was `{}`)",
1052
+ arg) ) ;
1057
1053
}
1058
1054
}
1059
1055
}
@@ -1062,7 +1058,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1062
1058
let gc = debugging_opts. gc ;
1063
1059
let debuginfo = if matches. opt_present ( "g" ) {
1064
1060
if cg. debuginfo . is_some ( ) {
1065
- early_error( output , "-g and -C debuginfo both provided" ) ;
1061
+ early_error ( error_format , "-g and -C debuginfo both provided" ) ;
1066
1062
}
1067
1063
FullDebugInfo
1068
1064
} else {
@@ -1071,16 +1067,16 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1071
1067
Some ( 1 ) => LimitedDebugInfo ,
1072
1068
Some ( 2 ) => FullDebugInfo ,
1073
1069
Some ( arg) => {
1074
- early_error( output , & format!( "debug info level needs to be between \
1075
- 0-2 (instead was `{}`)",
1076
- arg) ) ;
1070
+ early_error ( error_format , & format ! ( "debug info level needs to be between \
1071
+ 0-2 (instead was `{}`)",
1072
+ arg) ) ;
1077
1073
}
1078
1074
}
1079
1075
} ;
1080
1076
1081
1077
let mut search_paths = SearchPaths :: new ( ) ;
1082
1078
for s in & matches. opt_strs ( "L" ) {
1083
- search_paths. add_path( & s[ ..] , output ) ;
1079
+ search_paths. add_path ( & s[ ..] , error_format ) ;
1084
1080
}
1085
1081
1086
1082
let libs = matches. opt_strs ( "l" ) . into_iter ( ) . map ( |s| {
@@ -1092,9 +1088,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1092
1088
( Some ( name) , "framework" ) => ( name, cstore:: NativeFramework ) ,
1093
1089
( Some ( name) , "static" ) => ( name, cstore:: NativeStatic ) ,
1094
1090
( _, s) => {
1095
- early_error( output , & format!( "unknown library kind `{}`, expected \
1096
- one of dylib, framework, or static",
1097
- s) ) ;
1091
+ early_error ( error_format , & format ! ( "unknown library kind `{}`, expected \
1092
+ one of dylib, framework, or static",
1093
+ s) ) ;
1098
1094
}
1099
1095
} ;
1100
1096
( name. to_string ( ) , kind)
@@ -1109,26 +1105,26 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1109
1105
"file-names" => PrintRequest :: FileNames ,
1110
1106
"sysroot" => PrintRequest :: Sysroot ,
1111
1107
req => {
1112
- early_error( output , & format!( "unknown print request `{}`" , req) )
1108
+ early_error ( error_format , & format ! ( "unknown print request `{}`" , req) )
1113
1109
}
1114
1110
}
1115
1111
} ) . collect :: < Vec < _ > > ( ) ;
1116
1112
1117
1113
if !cg. remark . is_empty ( ) && debuginfo == NoDebugInfo {
1118
- early_warn( output , "-C remark will not show source locations without \
1119
- --debuginfo") ;
1114
+ early_warn ( error_format , "-C remark will not show source locations without \
1115
+ --debuginfo") ;
1120
1116
}
1121
1117
1122
1118
let mut externs = HashMap :: new ( ) ;
1123
1119
for arg in & matches. opt_strs ( "extern" ) {
1124
1120
let mut parts = arg. splitn ( 2 , '=' ) ;
1125
1121
let name = match parts. next ( ) {
1126
1122
Some ( s) => s,
1127
- None => early_error( output , "--extern value must not be empty" ) ,
1123
+ None => early_error ( error_format , "--extern value must not be empty" ) ,
1128
1124
} ;
1129
1125
let location = match parts. next ( ) {
1130
1126
Some ( s) => s,
1131
- None => early_error( output , "--extern value must be of the format `foo=bar`" ) ,
1127
+ None => early_error ( error_format , "--extern value must be of the format `foo=bar`" ) ,
1132
1128
} ;
1133
1129
1134
1130
externs. entry ( name. to_string ( ) ) . or_insert ( vec ! [ ] ) . push ( location. to_string ( ) ) ;
@@ -1159,7 +1155,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1159
1155
debugging_opts : debugging_opts,
1160
1156
prints : prints,
1161
1157
cg : cg,
1162
- output : output ,
1158
+ error_format : error_format ,
1163
1159
externs : externs,
1164
1160
crate_name : crate_name,
1165
1161
alt_std_name : None ,
0 commit comments