Rollup merge of #49046 - Zoxc:error-summary, r=michaelwoerister

Always print `aborting due to n previous error(s)`

r? @michaelwoerister
This commit is contained in:
kennytm 2018-03-25 01:26:24 +08:00 committed by GitHub
commit 9c5f372a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 114 additions and 52 deletions

View File

@ -63,6 +63,7 @@ use rustc_resolve as resolve;
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 @@ fn run_compiler_impl<'a>(args: &[String],
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.

View File

@ -558,21 +558,15 @@ impl Handler {
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();
@ -603,8 +597,16 @@ impl Handler {
}
}
}
}
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 {

View File

@ -27,6 +27,7 @@ use std::slice;
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 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
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!(),
}

View File

@ -6,3 +6,5 @@ LL | #[derive(Foo, Bar)] //~ ERROR proc-macro derive panicked
|
= help: message: lolnope
error: aborting due to previous error

View File

@ -6,3 +6,5 @@ LL | #[derive(A)]
|
= help: message: nope!
error: aborting due to previous error

View File

@ -4,5 +4,6 @@ error[E0404]: expected trait, found type alias `Bar`
LL | impl Bar for Baz { } //~ ERROR expected trait, found type alias
| ^^^ type aliases cannot be used for traits
error: cannot continue compilation due to previous error
error: aborting due to previous error
For more information about this error, try `rustc --explain E0404`.

View File

@ -9,3 +9,5 @@ LL | _
LL | underscore!();
| -------------- in this macro invocation
error: aborting due to previous error

View File

@ -9,3 +9,5 @@ LL | recurse!(0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9);
|
= help: consider adding a `#![recursion_limit="20"]` attribute to your crate
error: aborting due to previous error

View File

@ -10,5 +10,6 @@ error[E0404]: expected trait, found struct `Foo`
LL | fn baz<T: Foo>(_: T) {} //~ ERROR E0404
| ^^^ not a trait
error: cannot continue compilation due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0404`.

View File

@ -4,5 +4,6 @@ error[E0405]: cannot find trait `SomeTrait` in this scope
LL | impl SomeTrait for Foo {} //~ ERROR E0405
| ^^^^^^^^^ not found in this scope
error: cannot continue compilation due to previous error
error: aborting due to previous error
For more information about this error, try `rustc --explain E0405`.

View File

@ -4,3 +4,5 @@ error: compilation successful
LL | fn main() {} //~ ERROR compilation successful
| ^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -20,3 +20,5 @@ error: compilation successful
LL | fn main() {} //~ ERROR compilation successful
| ^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -1316,3 +1316,5 @@ LL | | println!("Hello World");
LL | | }
| |_^
error: aborting due to previous error

View File

@ -6,3 +6,5 @@ LL | | println!("Hello World");
LL | | }
| |_^
error: aborting due to previous error

View File

@ -24,5 +24,7 @@ help: possible candidate is found in another module, you can import it into scop
LL | use std::fmt::Debug;
|
error: cannot continue compilation due to previous error
error: aborting due to 3 previous errors
Some errors occurred: E0405, E0425.
For more information about an error, try `rustc --explain E0405`.

View File

@ -89,3 +89,5 @@ error: expected type, found `4`
LL | println!("{}", a: &mut 4); //~ ERROR expected type, found `4`
| ^ expecting a type here because of type ascription
error: aborting due to 9 previous errors

View File

@ -13,3 +13,5 @@ LL | bar(baz: $rest)
LL | foo!(true); //~ ERROR expected type, found keyword
| ^^^^ expecting a type here because of type ascription
error: aborting due to 2 previous errors

View File

@ -22,3 +22,5 @@ LL | | let _y = bar();
LL | | }
| |_^
error: aborting due to previous error

View File

@ -70,3 +70,5 @@ LL | | foo();
LL | | }
| |_^
error: aborting due to previous error

View File

@ -73,3 +73,5 @@ LL | | foo();
LL | | }
| |_^
error: aborting due to previous error

View File

@ -108,3 +108,5 @@ LL | | foo();
LL | | }
| |_^
error: aborting due to previous error

View File

@ -14,3 +14,5 @@ LL | | foo();
LL | | }
| |_^
error: aborting due to previous error

View File

@ -43,3 +43,5 @@ LL | () => ( i ; typeof ); //~ ERROR expected expression, found reserved k
LL | m!();
| ----- in this macro invocation
error: aborting due to 4 previous errors

View File

@ -4,5 +4,6 @@ error[E0433]: failed to resolve. Use of undeclared type or module `m`
LL | foo!(m::m2::A); //~ ERROR failed to resolve
| ^ Use of undeclared type or module `m`
error: cannot continue compilation due to previous error
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.

View File

@ -45,3 +45,5 @@ LL | my_recursive_macro!();
= note: expanding `my_recursive_macro! { }`
= note: to `my_recursive_macro ! ( ) ;`
error: aborting due to 2 previous errors

View File

@ -6,3 +6,5 @@ LL | let x = r##"lol"#;
|
= note: this raw string should be terminated with `"##`
error: aborting due to previous error

View File

@ -45,5 +45,7 @@ help: possible candidate is found in another module, you can import it into scop
LL | use std::ops::Div;
|
error: cannot continue compilation due to previous error
error: aborting due to 4 previous errors
Some errors occurred: E0405, E0412.
For more information about an error, try `rustc --explain E0405`.

View File

@ -8,5 +8,6 @@ help: possible candidate is found in another module, you can import it into scop
LL | use foo::bar::T;
|
error: cannot continue compilation due to previous error
error: aborting due to previous error
For more information about this error, try `rustc --explain E0405`.

View File

@ -8,5 +8,6 @@ help: possible candidate is found in another module, you can import it into scop
LL | use issue_21221_3::outer::OuterTrait;
|
error: cannot continue compilation due to previous error
error: aborting due to previous error
For more information about this error, try `rustc --explain E0405`.

View File

@ -8,5 +8,6 @@ help: possible candidate is found in another module, you can import it into scop
LL | use issue_21221_4::T;
|
error: cannot continue compilation due to previous error
error: aborting due to previous error
For more information about this error, try `rustc --explain E0405`.

View File

@ -8,5 +8,6 @@ help: possible better candidate is found in another module, you can import it in
LL | use issue_3907::Foo;
|
error: cannot continue compilation due to previous error
error: aborting due to previous error
For more information about this error, try `rustc --explain E0404`.

View File

@ -13,5 +13,7 @@ LL | impl K for isize {} //~ ERROR expected trait, found type alias `K`
| did you mean `I`?
| type aliases cannot be used for traits
error: cannot continue compilation due to previous error
error: aborting due to 2 previous errors
Some errors occurred: E0404, E0432.
For more information about an error, try `rustc --explain E0404`.

View File

@ -10,5 +10,7 @@ error[E0404]: expected trait, found type alias `Typedef`
LL | fn g<F:Typedef(isize) -> isize>(x: F) {}
| ^^^^^^^^^^^^^^^^^^^^^^^ type aliases cannot be used for traits
error: cannot continue compilation due to previous error
error: aborting due to 2 previous errors
Some errors occurred: E0404, E0405.
For more information about an error, try `rustc --explain E0404`.

View File

@ -1,2 +0,0 @@
error: cannot continue compilation due to previous error

View File

@ -36,3 +36,5 @@ LL | | println!("{}", theTwo);
LL | | }
| |_^
error: aborting due to previous error

View File

@ -8,5 +8,6 @@ help: possible better candidate is found in another module, you can import it in
LL | use std::ops::Add;
|
error: cannot continue compilation due to previous error
error: aborting due to previous error
For more information about this error, try `rustc --explain E0404`.