Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/librustc/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ use syntax::ast;
use syntax::parse::token;
use syntax::ptr::P;
use syntax_pos::{self, Pos, Span};
use errors::{DiagnosticBuilder, check_old_school};
use errors::DiagnosticBuilder;

impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn note_and_explain_region(self,
Expand Down Expand Up @@ -541,25 +541,19 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {

let span = origin.span();

let mut is_simple_error = false;

if let Some((expected, found)) = expected_found {
is_simple_error = if let &TypeError::Sorts(ref values) = terr {
let is_simple_error = if let &TypeError::Sorts(ref values) = terr {
values.expected.is_primitive() && values.found.is_primitive()
} else {
false
};

if !is_simple_error || check_old_school() {
if !is_simple_error {
diag.note_expected_found(&"type", &expected, &found);
}
}

if !is_simple_error && check_old_school() {
diag.span_note(span, &format!("{}", terr));
} else {
diag.span_label(span, &terr);
}
diag.span_label(span, &terr);

self.note_error_origin(diag, &origin);
self.check_and_note_conflicting_crates(diag, terr, span);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"NAME=PATH"),
opt::opt_s("", "sysroot", "Override the system root", "PATH"),
opt::multi_ubnr("Z", "", "Set internal debugging options", "FLAG"),
opt::opt_ubnr("", "error-format",
opt::opt_s("", "error-format",
"How errors and other messages are produced",
"human|json"),
opt::opt_s("", "color", "Configure coloring of output:
Expand Down
13 changes: 3 additions & 10 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use mir::transform as mir_pass;
use syntax::ast::{NodeId, Name};
use errors::{self, DiagnosticBuilder};
use errors::emitter::{Emitter, EmitterWriter};
use errors::snippet::FormatMode;
use syntax::json::JsonEmitter;
use syntax::feature_gate;
use syntax::parse;
Expand Down Expand Up @@ -369,9 +368,7 @@ pub fn build_session_with_codemap(sopts: config::Options,
let emitter: Box<Emitter> = match sopts.error_format {
config::ErrorOutputType::HumanReadable(color_config) => {
Box::new(EmitterWriter::stderr(color_config,
Some(registry),
Some(codemap.clone()),
errors::snippet::FormatMode::EnvironmentSelected))
Some(codemap.clone())))
}
config::ErrorOutputType::Json => {
Box::new(JsonEmitter::stderr(Some(registry), codemap.clone()))
Expand Down Expand Up @@ -509,9 +506,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
let emitter: Box<Emitter> = match output {
config::ErrorOutputType::HumanReadable(color_config) => {
Box::new(EmitterWriter::stderr(color_config,
None,
None,
FormatMode::EnvironmentSelected))
None))
}
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
};
Expand All @@ -524,9 +519,7 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
let emitter: Box<Emitter> = match output {
config::ErrorOutputType::HumanReadable(color_config) => {
Box::new(EmitterWriter::stderr(color_config,
None,
None,
FormatMode::EnvironmentSelected))
None))
}
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
};
Expand Down
8 changes: 2 additions & 6 deletions src/librustc_const_eval/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use std::cmp::Ordering;
use std::collections::hash_map::Entry::Vacant;

use rustc_const_math::*;
use rustc_errors::{DiagnosticBuilder, check_old_school};
use rustc_errors::DiagnosticBuilder;

macro_rules! math {
($e:expr, $op:expr) => {
Expand Down Expand Up @@ -378,11 +378,7 @@ pub fn note_const_eval_err<'a, 'tcx>(
{
match err.description() {
ConstEvalErrDescription::Simple(message) => {
if check_old_school() {
diag.note(&message);
} else {
diag.span_label(err.span, &message);
}
diag.span_label(err.span, &message);
}
}

Expand Down
15 changes: 3 additions & 12 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ use syntax::feature_gate::{GatedCfg, UnstableFeatures};
use syntax::parse::{self, PResult};
use syntax_pos::MultiSpan;
use errors::emitter::Emitter;
use errors::snippet::FormatMode;

#[cfg(test)]
pub mod test;
Expand Down Expand Up @@ -141,9 +140,7 @@ pub fn run(args: Vec<String>) -> isize {
None => {
let emitter =
errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
None,
None,
FormatMode::EnvironmentSelected);
None);
let handler = errors::Handler::with_emitter(true, false, Box::new(emitter));
handler.emit(&MultiSpan::new(),
&abort_msg(err_count),
Expand Down Expand Up @@ -381,10 +378,7 @@ fn check_cfg(sopts: &config::Options,
output: ErrorOutputType) {
let emitter: Box<Emitter> = match output {
config::ErrorOutputType::HumanReadable(color_config) => {
Box::new(errors::emitter::EmitterWriter::stderr(color_config,
None,
None,
FormatMode::EnvironmentSelected))
Box::new(errors::emitter::EmitterWriter::stderr(color_config, None))
}
config::ErrorOutputType::Json => Box::new(json::JsonEmitter::basic()),
};
Expand Down Expand Up @@ -1050,10 +1044,7 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
// Thread panicked without emitting a fatal diagnostic
if !value.is::<errors::FatalError>() {
let emitter =
Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
None,
None,
FormatMode::EnvironmentSelected));
Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None));
let handler = errors::Handler::with_emitter(true, false, emitter);

// a .span_bug or .bug call has already printed what
Expand Down
Loading