Skip to content

Commit

Permalink
Namespace use of diagnostic::ColorConfig
Browse files Browse the repository at this point in the history
With some other cleanup at the use sites.
  • Loading branch information
Keegan McAllister authored and LeoTestard committed Oct 7, 2015
1 parent e7b6056 commit 44fcecf
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl LintStore {
match (sess, from_plugin) {
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
(None, _) => early_error(diagnostic::Auto, &msg[..]),
(None, _) => early_error(diagnostic::ColorConfig::Auto, &msg[..]),
(Some(sess), false) => sess.bug(&msg[..]),

// A duplicate name from a plugin is a user error.
Expand All @@ -190,7 +190,7 @@ impl LintStore {
match (sess, from_plugin) {
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
(None, _) => early_error(diagnostic::Auto, &msg[..]),
(None, _) => early_error(diagnostic::ColorConfig::Auto, &msg[..]),
(Some(sess), false) => sess.bug(&msg[..]),

// A duplicate name from a plugin is a user error.
Expand Down
19 changes: 10 additions & 9 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use metadata::cstore;
use syntax::ast::{self, IntTy, UintTy};
use syntax::attr;
use syntax::attr::AttrMetaMethods;
use syntax::diagnostic::{ColorConfig, Auto, Always, Never, SpanHandler};
use syntax::diagnostic::{ColorConfig, SpanHandler};
use syntax::parse;
use syntax::parse::token::InternedString;
use syntax::feature_gate::UnstableFeatures;
Expand Down Expand Up @@ -216,7 +216,7 @@ pub fn basic_options() -> Options {
debugging_opts: basic_debugging_options(),
prints: Vec::new(),
cg: basic_codegen_options(),
color: Auto,
color: ColorConfig::Auto,
show_span: None,
externs: HashMap::new(),
crate_name: None,
Expand Down Expand Up @@ -854,16 +854,17 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {

pub fn build_session_options(matches: &getopts::Matches) -> Options {
let color = match matches.opt_str("color").as_ref().map(|s| &s[..]) {
Some("auto") => Auto,
Some("always") => Always,
Some("never") => Never,
Some("auto") => ColorConfig::Auto,
Some("always") => ColorConfig::Always,
Some("never") => ColorConfig::Never,

None => Auto,
None => ColorConfig::Auto,

Some(arg) => {
early_error(Auto, &format!("argument for --color must be auto, always \
or never (instead was `{}`)",
arg))
early_error(ColorConfig::Auto,
&format!("argument for --color must be auto, always \
or never (instead was `{}`)",
arg))
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl Target {
// this is 1. ugly, 2. error prone.


let handler = diagnostic::Handler::new(diagnostic::Auto, None, true);
let handler = diagnostic::Handler::new(diagnostic::ColorConfig::Auto, None, true);

let get_req_field = |name: &str| {
match obj.find(name)
Expand Down
12 changes: 7 additions & 5 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,15 +706,16 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
&opt.opt_group.short_name
};
if m.opt_present(opt_name) {
early_error(diagnostic::Auto, &format!("use of unstable option '{}' \
requires -Z unstable-options",
opt_name));
early_error(diagnostic::ColorConfig::Auto,
&format!("use of unstable option '{}' \
requires -Z unstable-options",
opt_name));
}
}
}
m
}
Err(f) => early_error(diagnostic::Auto, &f.to_string())
Err(f) => early_error(diagnostic::ColorConfig::Auto, &f.to_string())
}
}

Expand Down Expand Up @@ -819,7 +820,8 @@ pub fn monitor<F:FnOnce()+Send+'static>(f: F) {
Err(value) => {
// Thread panicked without emitting a fatal diagnostic
if !value.is::<diagnostic::FatalError>() {
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
let mut emitter = diagnostic::EmitterWriter::stderr(
diagnostic::ColorConfig::Auto, None);

// a .span_bug or .bug call has already printed what
// it wants to print.
Expand Down
7 changes: 3 additions & 4 deletions src/libsyntax/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

pub use self::Level::*;
pub use self::RenderSpan::*;
pub use self::ColorConfig::*;
use self::Destination::*;

use codemap::{self, COMMAND_LINE_SP, COMMAND_LINE_EXPN, Pos, Span};
Expand Down Expand Up @@ -342,9 +341,9 @@ impl EmitterWriter {
let stderr = io::stderr();

let use_color = match color_config {
Always => true,
Never => false,
Auto => stderr_isatty(),
ColorConfig::Always => true,
ColorConfig::Never => false,
ColorConfig::Auto => stderr_isatty()
};

if use_color {
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use ast;
use codemap::{self, Span, CodeMap, FileMap};
use diagnostic::{SpanHandler, Handler, Auto, FatalError};
use diagnostic::{SpanHandler, Handler, ColorConfig, FatalError};
use parse::attr::ParserAttr;
use parse::parser::Parser;
use parse::token::InternedString;
Expand Down Expand Up @@ -48,7 +48,7 @@ pub struct ParseSess {

impl ParseSess {
pub fn new() -> ParseSess {
let handler = SpanHandler::new(Handler::new(Auto, None, true), CodeMap::new());
let handler = SpanHandler::new(Handler::new(ColorConfig::Auto, None, true), CodeMap::new());
ParseSess::with_span_handler(handler)
}

Expand Down

0 comments on commit 44fcecf

Please sign in to comment.