Always print aborting due to n previous error(s)
and only print it once for multi-threaded code
This commit is contained in:
parent
3b43dcbb4c
commit
910bf840cc
@ -63,6 +63,7 @@
|
||||
use rustc_save_analysis as save;
|
||||
use rustc_save_analysis::DumpHandler;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_data_structures::OnDrop;
|
||||
use rustc::session::{self, config, Session, build_session, CompileResult};
|
||||
use rustc::session::CompileIncomplete;
|
||||
use rustc::session::config::{Input, PrintRequest, ErrorOutputType};
|
||||
@ -515,30 +516,35 @@ macro_rules! do_or_return {($expr: expr, $sess: expr) => {
|
||||
target_features::add_configuration(&mut cfg, &sess, &*trans);
|
||||
sess.parse_sess.config = cfg;
|
||||
|
||||
let plugins = sess.opts.debugging_opts.extra_plugins.clone();
|
||||
let result = {
|
||||
let plugins = sess.opts.debugging_opts.extra_plugins.clone();
|
||||
|
||||
let cstore = CStore::new(trans.metadata_loader());
|
||||
let cstore = CStore::new(trans.metadata_loader());
|
||||
|
||||
do_or_return!(callbacks.late_callback(&*trans,
|
||||
&matches,
|
||||
&sess,
|
||||
&cstore,
|
||||
&input,
|
||||
&odir,
|
||||
&ofile), Some(sess));
|
||||
do_or_return!(callbacks.late_callback(&*trans,
|
||||
&matches,
|
||||
&sess,
|
||||
&cstore,
|
||||
&input,
|
||||
&odir,
|
||||
&ofile), Some(sess));
|
||||
|
||||
let control = callbacks.build_controller(&sess, &matches);
|
||||
let _sess_abort_error = OnDrop(|| sess.diagnostic().print_error_count());
|
||||
|
||||
(driver::compile_input(trans,
|
||||
&sess,
|
||||
&cstore,
|
||||
&input_file_path,
|
||||
&input,
|
||||
&odir,
|
||||
&ofile,
|
||||
Some(plugins),
|
||||
&control),
|
||||
Some(sess))
|
||||
let control = callbacks.build_controller(&sess, &matches);
|
||||
|
||||
driver::compile_input(trans,
|
||||
&sess,
|
||||
&cstore,
|
||||
&input_file_path,
|
||||
&input,
|
||||
&odir,
|
||||
&ofile,
|
||||
Some(plugins),
|
||||
&control)
|
||||
};
|
||||
|
||||
(result, Some(sess))
|
||||
}
|
||||
|
||||
// Extract output directory and file from matches.
|
||||
|
@ -555,21 +555,15 @@ pub fn err_count(&self) -> usize {
|
||||
pub fn has_errors(&self) -> bool {
|
||||
self.err_count() > 0
|
||||
}
|
||||
pub fn abort_if_errors(&self) {
|
||||
let s;
|
||||
match self.err_count() {
|
||||
0 => {
|
||||
if let Some(bug) = self.delayed_span_bug.borrow_mut().take() {
|
||||
DiagnosticBuilder::new_diagnostic(self, bug).emit();
|
||||
}
|
||||
return;
|
||||
}
|
||||
1 => s = "aborting due to previous error".to_string(),
|
||||
_ => {
|
||||
s = format!("aborting due to {} previous errors", self.err_count());
|
||||
}
|
||||
}
|
||||
let err = self.fatal(&s);
|
||||
|
||||
pub fn print_error_count(&self) {
|
||||
let s = match self.err_count() {
|
||||
0 => return,
|
||||
1 => "aborting due to previous error".to_string(),
|
||||
_ => format!("aborting due to {} previous errors", self.err_count())
|
||||
};
|
||||
|
||||
let _ = self.fatal(&s);
|
||||
|
||||
let can_show_explain = self.emitter.borrow().should_show_explain();
|
||||
let are_there_diagnostics = !self.tracked_diagnostic_codes.borrow().is_empty();
|
||||
@ -600,8 +594,16 @@ pub fn abort_if_errors(&self) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err.raise();
|
||||
pub fn abort_if_errors(&self) {
|
||||
if self.err_count() == 0 {
|
||||
if let Some(bug) = self.delayed_span_bug.borrow_mut().take() {
|
||||
DiagnosticBuilder::new_diagnostic(self, bug).emit();
|
||||
}
|
||||
return;
|
||||
}
|
||||
FatalError.raise();
|
||||
}
|
||||
pub fn emit(&self, msp: &MultiSpan, msg: &str, lvl: Level) {
|
||||
if lvl == Warning && !self.flags.can_emit_warnings {
|
||||
|
@ -27,6 +27,7 @@
|
||||
use require_c_abi_if_variadic;
|
||||
use util::common::ErrorReported;
|
||||
use util::nodemap::FxHashSet;
|
||||
use errors::FatalError;
|
||||
|
||||
use std::iter;
|
||||
use syntax::{abi, ast};
|
||||
@ -337,7 +338,7 @@ fn trait_def_id(&self, trait_ref: &hir::TraitRef) -> DefId {
|
||||
Def::Trait(trait_def_id) => trait_def_id,
|
||||
Def::TraitAlias(alias_def_id) => alias_def_id,
|
||||
Def::Err => {
|
||||
self.tcx().sess.fatal("cannot continue compilation due to previous error");
|
||||
FatalError.raise();
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user