Skip to content

Commit 0616e86

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 8b41a59 + b1d872b commit 0616e86

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 30 additions & 24 deletions
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

Lines changed: 18 additions & 16 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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();

0 commit comments

Comments
 (0)