Skip to content

Commit

Permalink
Rollup merge of rust-lang#30384 - nrc:diagnostics, r=@nikomatsakis
Browse files Browse the repository at this point in the history
Should make it possible to add JSON or HTML errors. Also tidies up a lot.
  • Loading branch information
Manishearth committed Dec 18, 2015
2 parents cb319fc + ff0c74f commit c290296
Show file tree
Hide file tree
Showing 40 changed files with 856 additions and 773 deletions.
6 changes: 3 additions & 3 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use rustc_front::hir;
use rustc_front::util;
use rustc_front::intravisit as hir_visit;
use syntax::visit as ast_visit;
use syntax::diagnostic;
use syntax::errors;

/// Information about the registered lints.
///
Expand Down Expand Up @@ -167,7 +167,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(errors::ColorConfig::Auto, &msg[..]),
(Some(sess), false) => sess.bug(&msg[..]),

// A duplicate name from a plugin is a user error.
Expand All @@ -191,7 +191,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(errors::ColorConfig::Auto, &msg[..]),
(Some(sess), false) => sess.bug(&msg[..]),

// A duplicate name from a plugin is a user error.
Expand Down
32 changes: 16 additions & 16 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use middle::cstore;
use syntax::ast::{self, IntTy, UintTy};
use syntax::attr;
use syntax::attr::AttrMetaMethods;
use syntax::diagnostic::{ColorConfig, Auto, Always, Never, SpanHandler};
use syntax::errors::{ColorConfig, Handler};
use syntax::parse;
use syntax::parse::token::InternedString;
use syntax::feature_gate::UnstableFeatures;
Expand Down Expand Up @@ -238,7 +238,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 @@ -687,19 +687,19 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
v
}

pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
let target = match Target::search(&opts.target_triple) {
Ok(t) => t,
Err(e) => {
panic!(sp.handler().fatal(&format!("Error loading target specification: {}", e)));
panic!(sp.fatal(&format!("Error loading target specification: {}", e)));
}
};

let (int_type, uint_type) = match &target.target_pointer_width[..] {
"32" => (ast::TyI32, ast::TyU32),
"64" => (ast::TyI64, ast::TyU64),
w => panic!(sp.handler().fatal(&format!("target specification was invalid: \
unrecognized target-pointer-width {}", w))),
w => panic!(sp.fatal(&format!("target specification was invalid: \
unrecognized target-pointer-width {}", w))),
};

Config {
Expand Down Expand Up @@ -884,16 +884,16 @@ 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 Expand Up @@ -1224,7 +1224,7 @@ mod tests {
let sessopts = build_session_options(&matches);
let sess = build_session(sessopts, None, registry,
Rc::new(DummyCrateStore));
assert!(!sess.can_print_warnings);
assert!(!sess.diagnostic().can_emit_warnings);
}

{
Expand All @@ -1236,7 +1236,7 @@ mod tests {
let sessopts = build_session_options(&matches);
let sess = build_session(sessopts, None, registry,
Rc::new(DummyCrateStore));
assert!(sess.can_print_warnings);
assert!(sess.diagnostic().can_emit_warnings);
}

{
Expand All @@ -1247,7 +1247,7 @@ mod tests {
let sessopts = build_session_options(&matches);
let sess = build_session(sessopts, None, registry,
Rc::new(DummyCrateStore));
assert!(sess.can_print_warnings);
assert!(sess.diagnostic().can_emit_warnings);
}
}
}
Loading

0 comments on commit c290296

Please sign in to comment.