Skip to content

Commit 44fcecf

Browse files
kmcallisterLeoTestard
authored andcommitted
Namespace use of diagnostic::ColorConfig
With some other cleanup at the use sites.
1 parent e7b6056 commit 44fcecf

File tree

6 files changed

+25
-23
lines changed

6 files changed

+25
-23
lines changed

src/librustc/lint/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl LintStore {
166166
match (sess, from_plugin) {
167167
// We load builtin lints first, so a duplicate is a compiler bug.
168168
// Use early_error when handling -W help with no crate.
169-
(None, _) => early_error(diagnostic::Auto, &msg[..]),
169+
(None, _) => early_error(diagnostic::ColorConfig::Auto, &msg[..]),
170170
(Some(sess), false) => sess.bug(&msg[..]),
171171

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

196196
// A duplicate name from a plugin is a user error.

src/librustc/session/config.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use metadata::cstore;
2727
use syntax::ast::{self, IntTy, UintTy};
2828
use syntax::attr;
2929
use syntax::attr::AttrMetaMethods;
30-
use syntax::diagnostic::{ColorConfig, Auto, Always, Never, SpanHandler};
30+
use syntax::diagnostic::{ColorConfig, SpanHandler};
3131
use syntax::parse;
3232
use syntax::parse::token::InternedString;
3333
use syntax::feature_gate::UnstableFeatures;
@@ -216,7 +216,7 @@ pub fn basic_options() -> Options {
216216
debugging_opts: basic_debugging_options(),
217217
prints: Vec::new(),
218218
cg: basic_codegen_options(),
219-
color: Auto,
219+
color: ColorConfig::Auto,
220220
show_span: None,
221221
externs: HashMap::new(),
222222
crate_name: None,
@@ -854,16 +854,17 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
854854

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

861-
None => Auto,
861+
None => ColorConfig::Auto,
862862

863863
Some(arg) => {
864-
early_error(Auto, &format!("argument for --color must be auto, always \
865-
or never (instead was `{}`)",
866-
arg))
864+
early_error(ColorConfig::Auto,
865+
&format!("argument for --color must be auto, always \
866+
or never (instead was `{}`)",
867+
arg))
867868
}
868869
};
869870

src/librustc_back/target/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl Target {
250250
// this is 1. ugly, 2. error prone.
251251

252252

253-
let handler = diagnostic::Handler::new(diagnostic::Auto, None, true);
253+
let handler = diagnostic::Handler::new(diagnostic::ColorConfig::Auto, None, true);
254254

255255
let get_req_field = |name: &str| {
256256
match obj.find(name)

src/librustc_driver/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,15 +706,16 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
706706
&opt.opt_group.short_name
707707
};
708708
if m.opt_present(opt_name) {
709-
early_error(diagnostic::Auto, &format!("use of unstable option '{}' \
710-
requires -Z unstable-options",
711-
opt_name));
709+
early_error(diagnostic::ColorConfig::Auto,
710+
&format!("use of unstable option '{}' \
711+
requires -Z unstable-options",
712+
opt_name));
712713
}
713714
}
714715
}
715716
m
716717
}
717-
Err(f) => early_error(diagnostic::Auto, &f.to_string())
718+
Err(f) => early_error(diagnostic::ColorConfig::Auto, &f.to_string())
718719
}
719720
}
720721

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

824826
// a .span_bug or .bug call has already printed what
825827
// it wants to print.

src/libsyntax/diagnostic.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
pub use self::Level::*;
1212
pub use self::RenderSpan::*;
13-
pub use self::ColorConfig::*;
1413
use self::Destination::*;
1514

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

344343
let use_color = match color_config {
345-
Always => true,
346-
Never => false,
347-
Auto => stderr_isatty(),
344+
ColorConfig::Always => true,
345+
ColorConfig::Never => false,
346+
ColorConfig::Auto => stderr_isatty()
348347
};
349348

350349
if use_color {

src/libsyntax/parse/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use ast;
1414
use codemap::{self, Span, CodeMap, FileMap};
15-
use diagnostic::{SpanHandler, Handler, Auto, FatalError};
15+
use diagnostic::{SpanHandler, Handler, ColorConfig, FatalError};
1616
use parse::attr::ParserAttr;
1717
use parse::parser::Parser;
1818
use parse::token::InternedString;
@@ -48,7 +48,7 @@ pub struct ParseSess {
4848

4949
impl ParseSess {
5050
pub fn new() -> ParseSess {
51-
let handler = SpanHandler::new(Handler::new(Auto, None, true), CodeMap::new());
51+
let handler = SpanHandler::new(Handler::new(ColorConfig::Auto, None, true), CodeMap::new());
5252
ParseSess::with_span_handler(handler)
5353
}
5454

0 commit comments

Comments
 (0)