Skip to content

Commit c290296

Browse files
committed
Rollup merge of rust-lang#30384 - nrc:diagnostics, r=@nikomatsakis
Should make it possible to add JSON or HTML errors. Also tidies up a lot.
2 parents cb319fc + ff0c74f commit c290296

File tree

40 files changed

+856
-773
lines changed

40 files changed

+856
-773
lines changed

src/librustc/lint/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use rustc_front::hir;
4747
use rustc_front::util;
4848
use rustc_front::intravisit as hir_visit;
4949
use syntax::visit as ast_visit;
50-
use syntax::diagnostic;
50+
use syntax::errors;
5151

5252
/// Information about the registered lints.
5353
///
@@ -167,7 +167,7 @@ impl LintStore {
167167
match (sess, from_plugin) {
168168
// We load builtin lints first, so a duplicate is a compiler bug.
169169
// Use early_error when handling -W help with no crate.
170-
(None, _) => early_error(diagnostic::Auto, &msg[..]),
170+
(None, _) => early_error(errors::ColorConfig::Auto, &msg[..]),
171171
(Some(sess), false) => sess.bug(&msg[..]),
172172

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

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

src/librustc/session/config.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use middle::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::errors::{ColorConfig, Handler};
3131
use syntax::parse;
3232
use syntax::parse::token::InternedString;
3333
use syntax::feature_gate::UnstableFeatures;
@@ -238,7 +238,7 @@ pub fn basic_options() -> Options {
238238
debugging_opts: basic_debugging_options(),
239239
prints: Vec::new(),
240240
cg: basic_codegen_options(),
241-
color: Auto,
241+
color: ColorConfig::Auto,
242242
show_span: None,
243243
externs: HashMap::new(),
244244
crate_name: None,
@@ -687,19 +687,19 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
687687
v
688688
}
689689

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

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

705705
Config {
@@ -884,16 +884,16 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
884884

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

891-
None => Auto,
891+
None => ColorConfig::Auto,
892892

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

@@ -1224,7 +1224,7 @@ mod tests {
12241224
let sessopts = build_session_options(&matches);
12251225
let sess = build_session(sessopts, None, registry,
12261226
Rc::new(DummyCrateStore));
1227-
assert!(!sess.can_print_warnings);
1227+
assert!(!sess.diagnostic().can_emit_warnings);
12281228
}
12291229

12301230
{
@@ -1236,7 +1236,7 @@ mod tests {
12361236
let sessopts = build_session_options(&matches);
12371237
let sess = build_session(sessopts, None, registry,
12381238
Rc::new(DummyCrateStore));
1239-
assert!(sess.can_print_warnings);
1239+
assert!(sess.diagnostic().can_emit_warnings);
12401240
}
12411241

12421242
{
@@ -1247,7 +1247,7 @@ mod tests {
12471247
let sessopts = build_session_options(&matches);
12481248
let sess = build_session(sessopts, None, registry,
12491249
Rc::new(DummyCrateStore));
1250-
assert!(sess.can_print_warnings);
1250+
assert!(sess.diagnostic().can_emit_warnings);
12511251
}
12521252
}
12531253
}

0 commit comments

Comments
 (0)