Skip to content

Commit

Permalink
Rollup merge of rust-lang#49046 - Zoxc:error-summary, r=michaelwoerister
Browse files Browse the repository at this point in the history
Always print `aborting due to n previous error(s)`
  • Loading branch information
kennytm committed Mar 24, 2018
2 parents 175595a + b1d872b commit 0acfcb8
Show file tree
Hide file tree
Showing 36 changed files with 118 additions and 56 deletions.
54 changes: 30 additions & 24 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 cstore = CStore::new(trans.metadata_loader());

do_or_return!(callbacks.late_callback(&*trans,
&matches,
&sess,
&cstore,
&input,
&odir,
&ofile), Some(sess));

let control = callbacks.build_controller(&sess, &matches);

(driver::compile_input(trans,
&sess,
&cstore,
&input_file_path,
&input,
&odir,
&ofile,
Some(plugins),
&control),
Some(sess))
let result = {
let plugins = sess.opts.debugging_opts.extra_plugins.clone();

let cstore = CStore::new(trans.metadata_loader());

do_or_return!(callbacks.late_callback(&*trans,
&matches,
&sess,
&cstore,
&input,
&odir,
&ofile), Some(sess));

let _sess_abort_error = OnDrop(|| sess.diagnostic().print_error_count());

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.
Expand Down
34 changes: 18 additions & 16 deletions src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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!(),
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/custom-derive/issue-36935.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #[derive(Foo, Bar)] //~ ERROR proc-macro derive panicked
|
= help: message: lolnope

error: aborting due to previous error

2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/proc-macro/load-panic.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #[derive(A)]
|
= help: message: nope!

error: aborting due to previous error

3 changes: 2 additions & 1 deletion src/test/ui/codemap_tests/two_files.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
2 changes: 2 additions & 0 deletions src/test/ui/cross-file-errors/main.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ LL | _
LL | underscore!();
| -------------- in this macro invocation

error: aborting due to previous error

2 changes: 2 additions & 0 deletions src/test/ui/did_you_mean/recursion_limit_macro.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

3 changes: 2 additions & 1 deletion src/test/ui/error-codes/E0404.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
3 changes: 2 additions & 1 deletion src/test/ui/error-codes/E0405.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
2 changes: 2 additions & 0 deletions src/test/ui/feature-gate-fn_must_use-cap-lints-allow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ error: compilation successful
LL | fn main() {} //~ ERROR compilation successful
| ^^^^^^^^^^^^

error: aborting due to previous error

2 changes: 2 additions & 0 deletions src/test/ui/feature-gate-fn_must_use.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ error: compilation successful
LL | fn main() {} //~ ERROR compilation successful
| ^^^^^^^^^^^^

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -1316,3 +1316,5 @@ LL | | println!("Hello World");
LL | | }
| |_^

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | | println!("Hello World");
LL | | }
| |_^

error: aborting due to previous error

4 changes: 3 additions & 1 deletion src/test/ui/impl-trait/universal_wrong_bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
2 changes: 2 additions & 0 deletions src/test/ui/issue-22644.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 2 additions & 0 deletions src/test/ui/issue-44406.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 2 additions & 0 deletions src/test/ui/lint-output-format-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ LL | | let _y = bar();
LL | | }
| |_^

error: aborting due to previous error

2 changes: 2 additions & 0 deletions src/test/ui/loops-reject-duplicate-labels-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ LL | | foo();
LL | | }
| |_^

error: aborting due to previous error

2 changes: 2 additions & 0 deletions src/test/ui/loops-reject-duplicate-labels.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ LL | | foo();
LL | | }
| |_^

error: aborting due to previous error

2 changes: 2 additions & 0 deletions src/test/ui/loops-reject-labels-shadowing-lifetimes.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ LL | | foo();
LL | | }
| |_^

error: aborting due to previous error

2 changes: 2 additions & 0 deletions src/test/ui/loops-reject-lifetime-shadowing-label.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ LL | | foo();
LL | | }
| |_^

error: aborting due to previous error

2 changes: 2 additions & 0 deletions src/test/ui/macro-context.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

3 changes: 2 additions & 1 deletion src/test/ui/macros/macro_path_as_generic_bound.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
2 changes: 2 additions & 0 deletions src/test/ui/macros/trace_faulty_macros.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 2 additions & 0 deletions src/test/ui/raw_string.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | let x = r##"lol"#;
|
= note: this raw string should be terminated with `"##`

error: aborting due to previous error

4 changes: 3 additions & 1 deletion src/test/ui/resolve/issue-21221-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
3 changes: 2 additions & 1 deletion src/test/ui/resolve/issue-21221-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
3 changes: 2 additions & 1 deletion src/test/ui/resolve/issue-21221-3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
3 changes: 2 additions & 1 deletion src/test/ui/resolve/issue-21221-4.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
3 changes: 2 additions & 1 deletion src/test/ui/resolve/issue-3907.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
4 changes: 3 additions & 1 deletion src/test/ui/resolve/issue-5035.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
error: cannot continue compilation due to previous error

2 changes: 2 additions & 0 deletions src/test/ui/span/issue-24690.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ LL | | println!("{}", theTwo);
LL | | }
| |_^

error: aborting due to previous error

3 changes: 2 additions & 1 deletion src/test/ui/span/issue-35987.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

0 comments on commit 0acfcb8

Please sign in to comment.