@@ -27,7 +27,8 @@ use metadata::cstore;
27
27
use syntax:: ast:: { self , IntTy , UintTy } ;
28
28
use syntax:: attr;
29
29
use syntax:: attr:: AttrMetaMethods ;
30
- use syntax:: diagnostic:: { ColorConfig , SpanHandler } ;
30
+ use syntax:: diagnostic;
31
+ use syntax:: diagnostic:: { ColorConfig , EmitterConfig , SpanHandler } ;
31
32
use syntax:: parse;
32
33
use syntax:: parse:: token:: InternedString ;
33
34
use syntax:: feature_gate:: UnstableFeatures ;
@@ -37,6 +38,7 @@ use std::collections::HashMap;
37
38
use std:: env;
38
39
use std:: fmt;
39
40
use std:: path:: PathBuf ;
41
+ use std:: default;
40
42
41
43
use llvm;
42
44
@@ -106,7 +108,7 @@ pub struct Options {
106
108
pub debugging_opts : DebuggingOptions ,
107
109
pub prints : Vec < PrintRequest > ,
108
110
pub cg : CodegenOptions ,
109
- pub color : ColorConfig ,
111
+ pub emit_cfg : diagnostic :: EmitterConfig ,
110
112
pub show_span : Option < String > ,
111
113
pub externs : HashMap < String , Vec < String > > ,
112
114
pub crate_name : Option < String > ,
@@ -216,7 +218,7 @@ pub fn basic_options() -> Options {
216
218
debugging_opts : basic_debugging_options ( ) ,
217
219
prints : Vec :: new ( ) ,
218
220
cg : basic_codegen_options ( ) ,
219
- color : ColorConfig :: Auto ,
221
+ emit_cfg : default :: Default :: default ( ) ,
220
222
show_span : None ,
221
223
externs : HashMap :: new ( ) ,
222
224
crate_name : None ,
@@ -284,7 +286,7 @@ macro_rules! options {
284
286
$struct_name { $( $opt: $init) ,* }
285
287
}
286
288
287
- pub fn $buildfn( matches: & getopts:: Matches , color : ColorConfig ) -> $struct_name
289
+ pub fn $buildfn( matches: & getopts:: Matches , cfg : EmitterConfig ) -> $struct_name
288
290
{
289
291
let mut op = $defaultfn( ) ;
290
292
for option in matches. opt_strs( $prefix) {
@@ -298,17 +300,17 @@ macro_rules! options {
298
300
if !setter( & mut op, value) {
299
301
match ( value, opt_type_desc) {
300
302
( Some ( ..) , None ) => {
301
- early_error( color , & format!( "{} option `{}` takes no \
303
+ early_error( cfg , & format!( "{} option `{}` takes no \
302
304
value", $outputname, key) )
303
305
}
304
306
( None , Some ( type_desc) ) => {
305
- early_error( color , & format!( "{0} option `{1}` requires \
307
+ early_error( cfg , & format!( "{0} option `{1}` requires \
306
308
{2} ({3} {1}=<value>)",
307
309
$outputname, key,
308
310
type_desc, $prefix) )
309
311
}
310
312
( Some ( value) , Some ( type_desc) ) => {
311
- early_error( color , & format!( "incorrect value `{}` for {} \
313
+ early_error( cfg , & format!( "incorrect value `{}` for {} \
312
314
option `{}` - {} was expected",
313
315
value, $outputname,
314
316
key, type_desc) )
@@ -320,7 +322,7 @@ macro_rules! options {
320
322
break ;
321
323
}
322
324
if !found {
323
- early_error( color , & format!( "unknown {} option: `{}`" ,
325
+ early_error( cfg , & format!( "unknown {} option: `{}`" ,
324
326
$outputname, key) ) ;
325
327
}
326
328
}
@@ -822,6 +824,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
822
824
auto = colorize, if output goes to a tty (default);
823
825
always = always colorize output;
824
826
never = never colorize output" , "auto|always|never" ) ,
827
+ opt:: flag ( "" , "drawing" , "Use drawing characters in diagnostic output" ) ,
825
828
826
829
opt:: flagopt_u ( "" , "pretty" ,
827
830
"Pretty-print the input instead of compiling;
@@ -853,24 +856,28 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
853
856
}
854
857
855
858
pub fn build_session_options ( matches : & getopts:: Matches ) -> Options {
856
- let color = match matches. opt_str ( "color" ) . as_ref ( ) . map ( |s| & s[ ..] ) {
859
+ let mut emit_cfg: diagnostic:: EmitterConfig = default:: Default :: default ( ) ;
860
+ emit_cfg. color = match matches. opt_str ( "color" ) . as_ref ( ) . map ( |s| & s[ ..] ) {
857
861
Some ( "auto" ) => ColorConfig :: Auto ,
858
862
Some ( "always" ) => ColorConfig :: Always ,
859
863
Some ( "never" ) => ColorConfig :: Never ,
860
864
861
865
None => ColorConfig :: Auto ,
862
866
863
867
Some ( arg) => {
864
- early_error ( ColorConfig :: Auto ,
868
+ early_error ( emit_cfg ,
865
869
& format ! ( "argument for --color must be auto, always \
866
870
or never (instead was `{}`)",
867
871
arg) )
868
872
}
869
873
} ;
874
+ if matches. opt_present ( "drawing" ) {
875
+ emit_cfg. drawing = true ;
876
+ }
870
877
871
878
let unparsed_crate_types = matches. opt_strs ( "crate-type" ) ;
872
879
let crate_types = parse_crate_types_from_list ( unparsed_crate_types)
873
- . unwrap_or_else ( |e| early_error ( color , & e[ ..] ) ) ;
880
+ . unwrap_or_else ( |e| early_error ( emit_cfg , & e[ ..] ) ) ;
874
881
875
882
let mut lint_opts = vec ! ( ) ;
876
883
let mut describe_lints = false ;
@@ -887,11 +894,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
887
894
888
895
let lint_cap = matches. opt_str ( "cap-lints" ) . map ( |cap| {
889
896
lint:: Level :: from_str ( & cap) . unwrap_or_else ( || {
890
- early_error ( color , & format ! ( "unknown lint level: `{}`" , cap) )
897
+ early_error ( emit_cfg , & format ! ( "unknown lint level: `{}`" , cap) )
891
898
} )
892
899
} ) ;
893
900
894
- let debugging_opts = build_debugging_options ( matches, color ) ;
901
+ let debugging_opts = build_debugging_options ( matches, emit_cfg ) ;
895
902
896
903
let parse_only = debugging_opts. parse_only ;
897
904
let no_trans = debugging_opts. no_trans ;
@@ -916,7 +923,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
916
923
"link" => OutputType :: Exe ,
917
924
"dep-info" => OutputType :: DepInfo ,
918
925
part => {
919
- early_error ( color , & format ! ( "unknown emission type: `{}`" ,
926
+ early_error ( emit_cfg , & format ! ( "unknown emission type: `{}`" ,
920
927
part) )
921
928
}
922
929
} ;
@@ -929,15 +936,15 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
929
936
output_types. insert ( OutputType :: Exe , None ) ;
930
937
}
931
938
932
- let cg = build_codegen_options ( matches, color ) ;
939
+ let cg = build_codegen_options ( matches, emit_cfg ) ;
933
940
934
941
let sysroot_opt = matches. opt_str ( "sysroot" ) . map ( |m| PathBuf :: from ( & m) ) ;
935
942
let target = matches. opt_str ( "target" ) . unwrap_or (
936
943
host_triple ( ) . to_string ( ) ) ;
937
944
let opt_level = {
938
945
if matches. opt_present ( "O" ) {
939
946
if cg. opt_level . is_some ( ) {
940
- early_error ( color , "-O and -C opt-level both provided" ) ;
947
+ early_error ( emit_cfg , "-O and -C opt-level both provided" ) ;
941
948
}
942
949
Default
943
950
} else {
@@ -948,7 +955,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
948
955
Some ( 2 ) => Default ,
949
956
Some ( 3 ) => Aggressive ,
950
957
Some ( arg) => {
951
- early_error ( color , & format ! ( "optimization level needs to be \
958
+ early_error ( emit_cfg , & format ! ( "optimization level needs to be \
952
959
between 0-3 (instead was `{}`)",
953
960
arg) ) ;
954
961
}
@@ -959,7 +966,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
959
966
let gc = debugging_opts. gc ;
960
967
let debuginfo = if matches. opt_present ( "g" ) {
961
968
if cg. debuginfo . is_some ( ) {
962
- early_error ( color , "-g and -C debuginfo both provided" ) ;
969
+ early_error ( emit_cfg , "-g and -C debuginfo both provided" ) ;
963
970
}
964
971
FullDebugInfo
965
972
} else {
@@ -968,7 +975,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
968
975
Some ( 1 ) => LimitedDebugInfo ,
969
976
Some ( 2 ) => FullDebugInfo ,
970
977
Some ( arg) => {
971
- early_error ( color , & format ! ( "debug info level needs to be between \
978
+ early_error ( emit_cfg , & format ! ( "debug info level needs to be between \
972
979
0-2 (instead was `{}`)",
973
980
arg) ) ;
974
981
}
@@ -977,7 +984,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
977
984
978
985
let mut search_paths = SearchPaths :: new ( ) ;
979
986
for s in & matches. opt_strs ( "L" ) {
980
- search_paths. add_path ( & s[ ..] , color ) ;
987
+ search_paths. add_path ( & s[ ..] , emit_cfg ) ;
981
988
}
982
989
983
990
let libs = matches. opt_strs ( "l" ) . into_iter ( ) . map ( |s| {
@@ -989,7 +996,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
989
996
( Some ( name) , "framework" ) => ( name, cstore:: NativeFramework ) ,
990
997
( Some ( name) , "static" ) => ( name, cstore:: NativeStatic ) ,
991
998
( _, s) => {
992
- early_error ( color , & format ! ( "unknown library kind `{}`, expected \
999
+ early_error ( emit_cfg , & format ! ( "unknown library kind `{}`, expected \
993
1000
one of dylib, framework, or static",
994
1001
s) ) ;
995
1002
}
@@ -1006,13 +1013,13 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1006
1013
"file-names" => PrintRequest :: FileNames ,
1007
1014
"sysroot" => PrintRequest :: Sysroot ,
1008
1015
req => {
1009
- early_error ( color , & format ! ( "unknown print request `{}`" , req) )
1016
+ early_error ( emit_cfg , & format ! ( "unknown print request `{}`" , req) )
1010
1017
}
1011
1018
}
1012
1019
} ) . collect :: < Vec < _ > > ( ) ;
1013
1020
1014
1021
if !cg. remark . is_empty ( ) && debuginfo == NoDebugInfo {
1015
- early_warn ( color , "-C remark will not show source locations without \
1022
+ early_warn ( emit_cfg , "-C remark will not show source locations without \
1016
1023
--debuginfo") ;
1017
1024
}
1018
1025
@@ -1021,11 +1028,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1021
1028
let mut parts = arg. splitn ( 2 , '=' ) ;
1022
1029
let name = match parts. next ( ) {
1023
1030
Some ( s) => s,
1024
- None => early_error ( color , "--extern value must not be empty" ) ,
1031
+ None => early_error ( emit_cfg , "--extern value must not be empty" ) ,
1025
1032
} ;
1026
1033
let location = match parts. next ( ) {
1027
1034
Some ( s) => s,
1028
- None => early_error ( color , "--extern value must be of the format `foo=bar`" ) ,
1035
+ None => early_error ( emit_cfg , "--extern value must be of the format `foo=bar`" ) ,
1029
1036
} ;
1030
1037
1031
1038
externs. entry ( name. to_string ( ) ) . or_insert ( vec ! [ ] ) . push ( location. to_string ( ) ) ;
@@ -1055,7 +1062,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1055
1062
debugging_opts : debugging_opts,
1056
1063
prints : prints,
1057
1064
cg : cg,
1058
- color : color ,
1065
+ emit_cfg : emit_cfg ,
1059
1066
show_span : None ,
1060
1067
externs : externs,
1061
1068
crate_name : crate_name,
0 commit comments