@@ -12,6 +12,7 @@ use rustc_span::{
12
12
} ;
13
13
14
14
use crate :: config:: file_lines:: LineRange ;
15
+ use crate :: config:: options:: Color ;
15
16
use crate :: ignore_path:: IgnorePathSet ;
16
17
use crate :: parse:: parser:: { ModError , ModulePathSuccess } ;
17
18
use crate :: source_map:: LineRangeUtils ;
@@ -107,15 +108,26 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
107
108
}
108
109
}
109
110
111
+ impl From < Color > for ColorConfig {
112
+ fn from ( color : Color ) -> Self {
113
+ match color {
114
+ Color :: Auto => ColorConfig :: Auto ,
115
+ Color :: Always => ColorConfig :: Always ,
116
+ Color :: Never => ColorConfig :: Never ,
117
+ }
118
+ }
119
+ }
120
+
110
121
fn default_handler (
111
122
source_map : Lrc < SourceMap > ,
112
123
ignore_path_set : Lrc < IgnorePathSet > ,
113
124
can_reset : Lrc < AtomicBool > ,
114
125
hide_parse_errors : bool ,
126
+ color : Color ,
115
127
) -> Handler {
116
128
let supports_color = term:: stderr ( ) . map_or ( false , |term| term. supports_color ( ) ) ;
117
- let color_cfg = if supports_color {
118
- ColorConfig :: Auto
129
+ let emit_color = if supports_color {
130
+ ColorConfig :: from ( color )
119
131
} else {
120
132
ColorConfig :: Never
121
133
} ;
@@ -126,7 +138,7 @@ fn default_handler(
126
138
let fallback_bundle =
127
139
rustc_errors:: fallback_fluent_bundle ( rustc_errors:: DEFAULT_LOCALE_RESOURCES , false ) ;
128
140
Box :: new ( EmitterWriter :: stderr (
129
- color_cfg ,
141
+ emit_color ,
130
142
Some ( source_map. clone ( ) ) ,
131
143
None ,
132
144
fallback_bundle,
@@ -164,6 +176,7 @@ impl ParseSess {
164
176
Lrc :: clone ( & ignore_path_set) ,
165
177
Lrc :: clone ( & can_reset_errors) ,
166
178
config. hide_parse_errors ( ) ,
179
+ config. color ( ) ,
167
180
) ;
168
181
let parse_sess = RawParseSess :: with_span_handler ( handler, source_map) ;
169
182
0 commit comments