1
Fork 0

Respect --color when printing early errors

Currently, `early_error` and `early_warn` in `librustc::session` always
use `ColorConfig::Auto`. Modify them to follow the color configuration
set by the `--color` option.

As colored output is also printed during the early stage, parsing the
`--color` option should be done as early as possible. However, there are
still some cases when the output needs to be colored before knowing the
exact color settings. In these cases, it will be defaulted to
`ColorConfig::Auto`, which is the same as before.

Fixes #27879.
This commit is contained in:
Barosl Lee 2015-08-22 23:51:53 +09:00
parent e195aa84b4
commit 71f39c1a2f
7 changed files with 82 additions and 75 deletions

View file

@ -65,6 +65,7 @@ use externalfiles::ExternalHtml;
use serialize::Decodable;
use serialize::json::{self, Json};
use rustc::session::search_paths::SearchPaths;
use syntax::diagnostic;
// reexported from `clean` so it can be easily updated with the mod itself
pub use clean::SCHEMA_VERSION;
@ -227,7 +228,7 @@ pub fn main_args(args: &[String]) -> isize {
let mut libs = SearchPaths::new();
for s in &matches.opt_strs("L") {
libs.add_path(s);
libs.add_path(s, diagnostic::Auto);
}
let externs = match parse_externs(&matches) {
Ok(ex) => ex,
@ -362,7 +363,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
// First, parse the crate and extract all relevant information.
let mut paths = SearchPaths::new();
for s in &matches.opt_strs("L") {
paths.add_path(s);
paths.add_path(s, diagnostic::Auto);
}
let cfgs = matches.opt_strs("cfg");
let triple = matches.opt_str("target");