Skip to content

Commit a10dd4d

Browse files
authored
Rollup merge of rust-lang#49046 - Zoxc:error-summary, r=michaelwoerister
Always print `aborting due to n previous error(s)` r? @michaelwoerister
2 parents c2dbfa6 + b1d872b commit a10dd4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+143
-72
lines changed

src/librustc/middle/const_val.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use graphviz::IntoCow;
1919
use syntax_pos::Span;
2020

2121
use std::borrow::Cow;
22-
use std::rc::Rc;
22+
use rustc_data_structures::sync::Lrc;
2323

2424
pub type EvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, ConstEvalErr<'tcx>>;
2525

@@ -52,7 +52,7 @@ impl<'tcx> ConstVal<'tcx> {
5252
#[derive(Clone, Debug)]
5353
pub struct ConstEvalErr<'tcx> {
5454
pub span: Span,
55-
pub kind: Rc<ErrKind<'tcx>>,
55+
pub kind: Lrc<ErrKind<'tcx>>,
5656
}
5757

5858
#[derive(Clone, Debug)]

src/librustc/traits/query/dropck_outlives.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::iter::FromIterator;
1515
use traits::query::CanonicalTyGoal;
1616
use ty::{self, Ty, TyCtxt};
1717
use ty::subst::Kind;
18-
use std::rc::Rc;
18+
use rustc_data_structures::sync::Lrc;
1919

2020
impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
2121
/// Given a type `ty` of some value being dropped, computes a set
@@ -183,13 +183,13 @@ impl_stable_hash_for!(struct DropckOutlivesResult<'tcx> {
183183

184184
impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for QueryResult<'tcx, DropckOutlivesResult<'tcx>> {
185185
// we ought to intern this, but I'm too lazy just now
186-
type Canonicalized = Rc<Canonical<'gcx, QueryResult<'gcx, DropckOutlivesResult<'gcx>>>>;
186+
type Canonicalized = Lrc<Canonical<'gcx, QueryResult<'gcx, DropckOutlivesResult<'gcx>>>>;
187187

188188
fn intern(
189189
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
190190
value: Canonical<'gcx, Self::Lifted>,
191191
) -> Self::Canonicalized {
192-
Rc::new(value)
192+
Lrc::new(value)
193193
}
194194
}
195195

src/librustc/traits/query/normalize.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use infer::at::At;
1717
use infer::canonical::{Canonical, Canonicalize, QueryResult};
1818
use middle::const_val::ConstVal;
1919
use mir::interpret::GlobalId;
20-
use std::rc::Rc;
20+
use rustc_data_structures::sync::Lrc;
2121
use traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
2222
use traits::query::CanonicalProjectionGoal;
2323
use traits::project::Normalized;
@@ -259,13 +259,13 @@ impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for ty::ParamEnvAnd<'tcx, ty::Pr
259259

260260
impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for QueryResult<'tcx, NormalizationResult<'tcx>> {
261261
// we ought to intern this, but I'm too lazy just now
262-
type Canonicalized = Rc<Canonical<'gcx, QueryResult<'gcx, NormalizationResult<'gcx>>>>;
262+
type Canonicalized = Lrc<Canonical<'gcx, QueryResult<'gcx, NormalizationResult<'gcx>>>>;
263263

264264
fn intern(
265265
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
266266
value: Canonical<'gcx, Self::Lifted>,
267267
) -> Self::Canonicalized {
268-
Rc::new(value)
268+
Lrc::new(value)
269269
}
270270
}
271271

src/librustc/ty/structural_impls.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use ty::{self, Lift, Ty, TyCtxt};
1818
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
1919
use rustc_data_structures::accumulate_vec::AccumulateVec;
2020
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
21+
use rustc_data_structures::sync::Lrc;
2122
use mir::interpret;
2223

2324
use std::rc::Rc;
@@ -465,7 +466,7 @@ impl<'a, 'tcx> Lift<'tcx> for ConstEvalErr<'a> {
465466
tcx.lift(&*self.kind).map(|kind| {
466467
ConstEvalErr {
467468
span: self.span,
468-
kind: Rc::new(kind),
469+
kind: Lrc::new(kind),
469470
}
470471
})
471472
}

src/librustc_data_structures/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ pub mod flock;
7676
pub mod sync;
7777
pub mod owning_ref;
7878

79+
pub struct OnDrop<F: Fn()>(pub F);
80+
81+
impl<F: Fn()> Drop for OnDrop<F> {
82+
fn drop(&mut self) {
83+
(self.0)();
84+
}
85+
}
86+
7987
// See comments in src/librustc/lib.rs
8088
#[doc(hidden)]
8189
pub fn __noop_fix_for_27438() {}

src/librustc_driver/lib.rs

+30-24
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ use rustc_resolve as resolve;
6464
use rustc_save_analysis as save;
6565
use rustc_save_analysis::DumpHandler;
6666
use rustc_data_structures::sync::Lrc;
67+
use rustc_data_structures::OnDrop;
6768
use rustc::session::{self, config, Session, build_session, CompileResult};
6869
use rustc::session::CompileIncomplete;
6970
use rustc::session::config::{Input, PrintRequest, ErrorOutputType};
@@ -516,30 +517,35 @@ fn run_compiler_impl<'a>(args: &[String],
516517
target_features::add_configuration(&mut cfg, &sess, &*trans);
517518
sess.parse_sess.config = cfg;
518519

519-
let plugins = sess.opts.debugging_opts.extra_plugins.clone();
520-
521-
let cstore = CStore::new(trans.metadata_loader());
522-
523-
do_or_return!(callbacks.late_callback(&*trans,
524-
&matches,
525-
&sess,
526-
&cstore,
527-
&input,
528-
&odir,
529-
&ofile), Some(sess));
530-
531-
let control = callbacks.build_controller(&sess, &matches);
532-
533-
(driver::compile_input(trans,
534-
&sess,
535-
&cstore,
536-
&input_file_path,
537-
&input,
538-
&odir,
539-
&ofile,
540-
Some(plugins),
541-
&control),
542-
Some(sess))
520+
let result = {
521+
let plugins = sess.opts.debugging_opts.extra_plugins.clone();
522+
523+
let cstore = CStore::new(trans.metadata_loader());
524+
525+
do_or_return!(callbacks.late_callback(&*trans,
526+
&matches,
527+
&sess,
528+
&cstore,
529+
&input,
530+
&odir,
531+
&ofile), Some(sess));
532+
533+
let _sess_abort_error = OnDrop(|| sess.diagnostic().print_error_count());
534+
535+
let control = callbacks.build_controller(&sess, &matches);
536+
537+
driver::compile_input(trans,
538+
&sess,
539+
&cstore,
540+
&input_file_path,
541+
&input,
542+
&odir,
543+
&ofile,
544+
Some(plugins),
545+
&control)
546+
};
547+
548+
(result, Some(sess))
543549
}
544550

545551
// Extract output directory and file from matches.

src/librustc_errors/lib.rs

+18-16
Original file line numberDiff line numberDiff line change
@@ -558,21 +558,15 @@ impl Handler {
558558
pub fn has_errors(&self) -> bool {
559559
self.err_count() > 0
560560
}
561-
pub fn abort_if_errors(&self) {
562-
let s;
563-
match self.err_count() {
564-
0 => {
565-
if let Some(bug) = self.delayed_span_bug.borrow_mut().take() {
566-
DiagnosticBuilder::new_diagnostic(self, bug).emit();
567-
}
568-
return;
569-
}
570-
1 => s = "aborting due to previous error".to_string(),
571-
_ => {
572-
s = format!("aborting due to {} previous errors", self.err_count());
573-
}
574-
}
575-
let err = self.fatal(&s);
561+
562+
pub fn print_error_count(&self) {
563+
let s = match self.err_count() {
564+
0 => return,
565+
1 => "aborting due to previous error".to_string(),
566+
_ => format!("aborting due to {} previous errors", self.err_count())
567+
};
568+
569+
let _ = self.fatal(&s);
576570

577571
let can_show_explain = self.emitter.borrow().should_show_explain();
578572
let are_there_diagnostics = !self.tracked_diagnostic_codes.borrow().is_empty();
@@ -603,8 +597,16 @@ impl Handler {
603597
}
604598
}
605599
}
600+
}
606601

607-
err.raise();
602+
pub fn abort_if_errors(&self) {
603+
if self.err_count() == 0 {
604+
if let Some(bug) = self.delayed_span_bug.borrow_mut().take() {
605+
DiagnosticBuilder::new_diagnostic(self, bug).emit();
606+
}
607+
return;
608+
}
609+
FatalError.raise();
608610
}
609611
pub fn emit(&self, msp: &MultiSpan, msg: &str, lvl: Level) {
610612
if lvl == Warning && !self.flags.can_emit_warnings {

src/librustc_mir/interpret/const_eval.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::{Place, EvalContext, StackPopCleanup, ValTy, PlaceExtra, Memory};
1414

1515
use std::fmt;
1616
use std::error::Error;
17-
use std::rc::Rc;
17+
use rustc_data_structures::sync::Lrc;
1818

1919
pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>(
2020
tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -485,7 +485,7 @@ pub fn const_eval_provider<'a, 'tcx>(
485485
// Do match-check before building MIR
486486
if tcx.check_match(def_id).is_err() {
487487
return Err(ConstEvalErr {
488-
kind: Rc::new(CheckMatchError),
488+
kind: Lrc::new(CheckMatchError),
489489
span,
490490
});
491491
}
@@ -497,7 +497,7 @@ pub fn const_eval_provider<'a, 'tcx>(
497497
// Do not continue into miri if typeck errors occurred; it will fail horribly
498498
if tables.tainted_by_errors {
499499
return Err(ConstEvalErr {
500-
kind: Rc::new(TypeckError),
500+
kind: Lrc::new(TypeckError),
501501
span,
502502
});
503503
}

src/librustc_traits/dropck_outlives.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ use rustc::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResu
1616
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
1717
use rustc::ty::subst::Subst;
1818
use rustc::util::nodemap::FxHashSet;
19-
use std::rc::Rc;
19+
use rustc_data_structures::sync::Lrc;
2020
use syntax::codemap::{Span, DUMMY_SP};
2121
use util;
2222

2323
crate fn dropck_outlives<'tcx>(
2424
tcx: TyCtxt<'_, 'tcx, 'tcx>,
2525
goal: CanonicalTyGoal<'tcx>,
26-
) -> Result<Rc<Canonical<'tcx, QueryResult<'tcx, DropckOutlivesResult<'tcx>>>>, NoSolution> {
26+
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, DropckOutlivesResult<'tcx>>>>, NoSolution> {
2727
debug!("dropck_outlives(goal={:#?})", goal);
2828

2929
tcx.infer_ctxt().enter(|ref infcx| {

src/librustc_traits/normalize_projection_ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ use rustc::traits::{self, FulfillmentContext, Normalized, ObligationCause,
1414
use rustc::traits::query::{CanonicalProjectionGoal, NoSolution, normalize::NormalizationResult};
1515
use rustc::ty::{ParamEnvAnd, TyCtxt};
1616
use rustc::util::common::CellUsizeExt;
17-
use std::rc::Rc;
17+
use rustc_data_structures::sync::Lrc;
1818
use syntax::ast::DUMMY_NODE_ID;
1919
use syntax_pos::DUMMY_SP;
2020
use util;
2121

2222
crate fn normalize_projection_ty<'tcx>(
2323
tcx: TyCtxt<'_, 'tcx, 'tcx>,
2424
goal: CanonicalProjectionGoal<'tcx>,
25-
) -> Result<Rc<Canonical<'tcx, QueryResult<'tcx, NormalizationResult<'tcx>>>>, NoSolution> {
25+
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, NormalizationResult<'tcx>>>>, NoSolution> {
2626
debug!("normalize_provider(goal={:#?})", goal);
2727

2828
tcx.sess.perf_stats.normalize_projection_ty.increment();

src/librustc_typeck/astconv.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use std::slice;
2727
use require_c_abi_if_variadic;
2828
use util::common::ErrorReported;
2929
use util::nodemap::FxHashSet;
30+
use errors::FatalError;
3031

3132
use std::iter;
3233
use syntax::{abi, ast};
@@ -337,7 +338,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
337338
Def::Trait(trait_def_id) => trait_def_id,
338339
Def::TraitAlias(alias_def_id) => alias_def_id,
339340
Def::Err => {
340-
self.tcx().sess.fatal("cannot continue compilation due to previous error");
341+
FatalError.raise();
341342
}
342343
_ => unreachable!(),
343344
}

src/test/ui-fulldeps/custom-derive/issue-36935.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #[derive(Foo, Bar)] //~ ERROR proc-macro derive panicked
66
|
77
= help: message: lolnope
88

9+
error: aborting due to previous error
10+

src/test/ui-fulldeps/proc-macro/load-panic.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #[derive(A)]
66
|
77
= help: message: nope!
88

9+
error: aborting due to previous error
10+

src/test/ui/codemap_tests/two_files.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ error[E0404]: expected trait, found type alias `Bar`
44
LL | impl Bar for Baz { } //~ ERROR expected trait, found type alias
55
| ^^^ type aliases cannot be used for traits
66

7-
error: cannot continue compilation due to previous error
7+
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0404`.

src/test/ui/cross-file-errors/main.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ LL | _
99
LL | underscore!();
1010
| -------------- in this macro invocation
1111

12+
error: aborting due to previous error
13+

src/test/ui/did_you_mean/recursion_limit_macro.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -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);
99
|
1010
= help: consider adding a `#![recursion_limit="20"]` attribute to your crate
1111

12+
error: aborting due to previous error
13+

src/test/ui/error-codes/E0404.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ error[E0404]: expected trait, found struct `Foo`
1010
LL | fn baz<T: Foo>(_: T) {} //~ ERROR E0404
1111
| ^^^ not a trait
1212

13-
error: cannot continue compilation due to previous error
13+
error: aborting due to 2 previous errors
1414

15+
For more information about this error, try `rustc --explain E0404`.

src/test/ui/error-codes/E0405.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ error[E0405]: cannot find trait `SomeTrait` in this scope
44
LL | impl SomeTrait for Foo {} //~ ERROR E0405
55
| ^^^^^^^^^ not found in this scope
66

7-
error: cannot continue compilation due to previous error
7+
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0405`.

src/test/ui/feature-gate-fn_must_use-cap-lints-allow.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ error: compilation successful
44
LL | fn main() {} //~ ERROR compilation successful
55
| ^^^^^^^^^^^^
66

7+
error: aborting due to previous error
8+

src/test/ui/feature-gate-fn_must_use.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ error: compilation successful
2020
LL | fn main() {} //~ ERROR compilation successful
2121
| ^^^^^^^^^^^^
2222

23+
error: aborting due to previous error
24+

src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -1316,3 +1316,5 @@ LL | | println!("Hello World");
13161316
LL | | }
13171317
| |_^
13181318

1319+
error: aborting due to previous error
1320+

src/test/ui/feature-gate/issue-43106-gating-of-deprecated.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | | println!("Hello World");
66
LL | | }
77
| |_^
88

9+
error: aborting due to previous error
10+

src/test/ui/impl-trait/universal_wrong_bounds.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ help: possible candidate is found in another module, you can import it into scop
2424
LL | use std::fmt::Debug;
2525
|
2626

27-
error: cannot continue compilation due to previous error
27+
error: aborting due to 3 previous errors
2828

29+
Some errors occurred: E0405, E0425.
30+
For more information about an error, try `rustc --explain E0405`.

src/test/ui/issue-22644.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@ error: expected type, found `4`
8989
LL | println!("{}", a: &mut 4); //~ ERROR expected type, found `4`
9090
| ^ expecting a type here because of type ascription
9191

92+
error: aborting due to 9 previous errors
93+

src/test/ui/issue-44406.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ LL | bar(baz: $rest)
1313
LL | foo!(true); //~ ERROR expected type, found keyword
1414
| ^^^^ expecting a type here because of type ascription
1515

16+
error: aborting due to 2 previous errors
17+

src/test/ui/lint-output-format-2.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ LL | | let _y = bar();
2222
LL | | }
2323
| |_^
2424

25+
error: aborting due to previous error
26+

0 commit comments

Comments
 (0)