@@ -72,13 +72,13 @@ pub enum OutputType {
7272
7373#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
7474pub enum ErrorOutputType {
75- Tty ( ColorConfig ) ,
75+ HumanReadable ( ColorConfig ) ,
7676 Json ,
7777}
7878
7979impl Default for ErrorOutputType {
8080 fn default ( ) -> ErrorOutputType {
81- ErrorOutputType :: Tty ( ColorConfig :: Auto )
81+ ErrorOutputType :: HumanReadable ( ColorConfig :: Auto )
8282 }
8383}
8484
@@ -135,7 +135,7 @@ pub struct Options {
135135 pub test : bool ,
136136 pub parse_only : bool ,
137137 pub no_trans : bool ,
138- pub output : ErrorOutputType ,
138+ pub error_format : ErrorOutputType ,
139139 pub treat_err_as_bug : bool ,
140140 pub incremental_compilation : bool ,
141141 pub dump_dep_graph : bool ,
@@ -252,12 +252,7 @@ pub fn basic_options() -> Options {
252252 debugging_opts : basic_debugging_options ( ) ,
253253 prints : Vec :: new ( ) ,
254254 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 ( ) ,
261256 externs : HashMap :: new ( ) ,
262257 crate_name : None ,
263258 alt_std_name : None ,
@@ -324,7 +319,7 @@ macro_rules! options {
324319 $struct_name { $( $opt: $init) ,* }
325320 }
326321
327- pub fn $buildfn( matches: & getopts:: Matches , output : ErrorOutputType ) -> $struct_name
322+ pub fn $buildfn( matches: & getopts:: Matches , error_format : ErrorOutputType ) -> $struct_name
328323 {
329324 let mut op = $defaultfn( ) ;
330325 for option in matches. opt_strs( $prefix) {
@@ -338,20 +333,20 @@ macro_rules! options {
338333 if !setter( & mut op, value) {
339334 match ( value, opt_type_desc) {
340335 ( 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) )
343338 }
344339 ( 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) )
349344 }
350345 ( 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) )
355350 }
356351 ( None , None ) => unreachable!( )
357352 }
@@ -360,8 +355,8 @@ macro_rules! options {
360355 break ;
361356 }
362357 if !found {
363- early_error( output , & format!( "unknown {} option: `{}`" ,
364- $outputname, key) ) ;
358+ early_error( error_format , & format!( "unknown {} option: `{}`" ,
359+ $outputname, key) ) ;
365360 }
366361 }
367362 return op;
@@ -879,7 +874,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
879874 "NAME=PATH" ) ,
880875 opt:: opt ( "" , "sysroot" , "Override the system root" , "PATH" ) ,
881876 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" ) ,
883878 opt:: opt ( "" , "color" , "Configure coloring of output:
884879 auto = colorize, if output goes to a tty (default);
885880 always = always colorize output;
@@ -929,19 +924,20 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
929924 } ;
930925
931926 // 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
934929 // 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) ,
938933 Some ( "json" ) => ErrorOutputType :: Json ,
939934
940935 None => ErrorOutputType :: default ( ) ,
941936
942937 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+ `{}`)",
945941 arg) )
946942 }
947943 }
@@ -951,7 +947,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
951947
952948 let unparsed_crate_types = matches. opt_strs ( "crate-type" ) ;
953949 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[ ..] ) ) ;
955951
956952 let mut lint_opts = vec ! ( ) ;
957953 let mut describe_lints = false ;
@@ -968,11 +964,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
968964
969965 let lint_cap = matches. opt_str ( "cap-lints" ) . map ( |cap| {
970966 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) )
972968 } )
973969 } ) ;
974970
975- let debugging_opts = build_debugging_options( matches, output ) ;
971+ let debugging_opts = build_debugging_options ( matches, error_format ) ;
976972
977973 let parse_only = debugging_opts. parse_only ;
978974 let no_trans = debugging_opts. no_trans ;
@@ -998,7 +994,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
998994 "link" => OutputType :: Exe ,
999995 "dep-info" => OutputType :: DepInfo ,
1000996 part => {
1001- early_error( output , & format!( "unknown emission type: `{}`" ,
997+ early_error ( error_format , & format ! ( "unknown emission type: `{}`" ,
1002998 part) )
1003999 }
10041000 } ;
@@ -1011,7 +1007,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10111007 output_types. insert ( OutputType :: Exe , None ) ;
10121008 }
10131009
1014- let mut cg = build_codegen_options( matches, output ) ;
1010+ let mut cg = build_codegen_options ( matches, error_format ) ;
10151011
10161012 // Issue #30063: if user requests llvm-related output to one
10171013 // particular path, disable codegen-units.
@@ -1023,11 +1019,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10231019 } ) . collect ( ) ;
10241020 if !incompatible. is_empty ( ) {
10251021 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( ) ) ) ;
10291025 }
1030- early_warn( output , "resetting to default -C codegen-units=1" ) ;
1026+ early_warn ( error_format , "resetting to default -C codegen-units=1" ) ;
10311027 cg. codegen_units = 1 ;
10321028 }
10331029 }
@@ -1040,7 +1036,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10401036 let opt_level = {
10411037 if matches. opt_present ( "O" ) {
10421038 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" ) ;
10441040 }
10451041 OptLevel :: Default
10461042 } else {
@@ -1051,9 +1047,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10511047 Some ( 2 ) => OptLevel :: Default ,
10521048 Some ( 3 ) => OptLevel :: Aggressive ,
10531049 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) ) ;
10571053 }
10581054 }
10591055 }
@@ -1062,7 +1058,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10621058 let gc = debugging_opts. gc ;
10631059 let debuginfo = if matches. opt_present ( "g" ) {
10641060 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" ) ;
10661062 }
10671063 FullDebugInfo
10681064 } else {
@@ -1071,16 +1067,16 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10711067 Some ( 1 ) => LimitedDebugInfo ,
10721068 Some ( 2 ) => FullDebugInfo ,
10731069 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) ) ;
10771073 }
10781074 }
10791075 } ;
10801076
10811077 let mut search_paths = SearchPaths :: new ( ) ;
10821078 for s in & matches. opt_strs ( "L" ) {
1083- search_paths. add_path( & s[ ..] , output ) ;
1079+ search_paths. add_path ( & s[ ..] , error_format ) ;
10841080 }
10851081
10861082 let libs = matches. opt_strs ( "l" ) . into_iter ( ) . map ( |s| {
@@ -1092,9 +1088,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10921088 ( Some ( name) , "framework" ) => ( name, cstore:: NativeFramework ) ,
10931089 ( Some ( name) , "static" ) => ( name, cstore:: NativeStatic ) ,
10941090 ( _, 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) ) ;
10981094 }
10991095 } ;
11001096 ( name. to_string ( ) , kind)
@@ -1109,26 +1105,26 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
11091105 "file-names" => PrintRequest :: FileNames ,
11101106 "sysroot" => PrintRequest :: Sysroot ,
11111107 req => {
1112- early_error( output , & format!( "unknown print request `{}`" , req) )
1108+ early_error ( error_format , & format ! ( "unknown print request `{}`" , req) )
11131109 }
11141110 }
11151111 } ) . collect :: < Vec < _ > > ( ) ;
11161112
11171113 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") ;
11201116 }
11211117
11221118 let mut externs = HashMap :: new ( ) ;
11231119 for arg in & matches. opt_strs ( "extern" ) {
11241120 let mut parts = arg. splitn ( 2 , '=' ) ;
11251121 let name = match parts. next ( ) {
11261122 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" ) ,
11281124 } ;
11291125 let location = match parts. next ( ) {
11301126 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`" ) ,
11321128 } ;
11331129
11341130 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 {
11591155 debugging_opts : debugging_opts,
11601156 prints : prints,
11611157 cg : cg,
1162- output : output ,
1158+ error_format : error_format ,
11631159 externs : externs,
11641160 crate_name : crate_name,
11651161 alt_std_name : None ,
0 commit comments