Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always print aborting due to n previous error(s) #49046

Merged
merged 4 commits into from
Mar 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc/middle/const_val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use graphviz::IntoCow;
use syntax_pos::Span;

use std::borrow::Cow;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;

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

Expand Down Expand Up @@ -52,7 +52,7 @@ impl<'tcx> ConstVal<'tcx> {
#[derive(Clone, Debug)]
pub struct ConstEvalErr<'tcx> {
pub span: Span,
pub kind: Rc<ErrKind<'tcx>>,
pub kind: Lrc<ErrKind<'tcx>>,
}

#[derive(Clone, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/query/dropck_outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::iter::FromIterator;
use traits::query::CanonicalTyGoal;
use ty::{self, Ty, TyCtxt};
use ty::subst::Kind;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;

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

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

fn intern(
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
value: Canonical<'gcx, Self::Lifted>,
) -> Self::Canonicalized {
Rc::new(value)
Lrc::new(value)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/query/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use infer::at::At;
use infer::canonical::{Canonical, Canonicalize, QueryResult};
use middle::const_val::ConstVal;
use mir::interpret::GlobalId;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;
use traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
use traits::query::CanonicalProjectionGoal;
use traits::project::Normalized;
Expand Down Expand Up @@ -259,13 +259,13 @@ impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for ty::ParamEnvAnd<'tcx, ty::Pr

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

fn intern(
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
value: Canonical<'gcx, Self::Lifted>,
) -> Self::Canonicalized {
Rc::new(value)
Lrc::new(value)
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use ty::{self, Lift, Ty, TyCtxt};
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use rustc_data_structures::accumulate_vec::AccumulateVec;
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use rustc_data_structures::sync::Lrc;
use mir::interpret;

use std::rc::Rc;
Expand Down Expand Up @@ -465,7 +466,7 @@ impl<'a, 'tcx> Lift<'tcx> for ConstEvalErr<'a> {
tcx.lift(&*self.kind).map(|kind| {
ConstEvalErr {
span: self.span,
kind: Rc::new(kind),
kind: Lrc::new(kind),
}
})
}
Expand Down
8 changes: 8 additions & 0 deletions src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ pub mod flock;
pub mod sync;
pub mod owning_ref;

pub struct OnDrop<F: Fn()>(pub F);

impl<F: Fn()> Drop for OnDrop<F> {
fn drop(&mut self) {
(self.0)();
}
}

// See comments in src/librustc/lib.rs
#[doc(hidden)]
pub fn __noop_fix_for_27438() {}
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 @@ -555,21 +555,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 @@ -600,8 +594,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
6 changes: 3 additions & 3 deletions src/librustc_mir/interpret/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::{Place, EvalContext, StackPopCleanup, ValTy, PlaceExtra, Memory};

use std::fmt;
use std::error::Error;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;

pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
Expand Down Expand Up @@ -477,7 +477,7 @@ pub fn const_eval_provider<'a, 'tcx>(
// Do match-check before building MIR
if tcx.check_match(def_id).is_err() {
return Err(ConstEvalErr {
kind: Rc::new(CheckMatchError),
kind: Lrc::new(CheckMatchError),
span,
});
}
Expand All @@ -489,7 +489,7 @@ pub fn const_eval_provider<'a, 'tcx>(
// Do not continue into miri if typeck errors occurred; it will fail horribly
if tables.tainted_by_errors {
return Err(ConstEvalErr {
kind: Rc::new(TypeckError),
kind: Lrc::new(TypeckError),
span,
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_traits/dropck_outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ use rustc::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResu
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
use rustc::ty::subst::Subst;
use rustc::util::nodemap::FxHashSet;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;
use syntax::codemap::{Span, DUMMY_SP};
use util;

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

tcx.infer_ctxt().enter(|ref infcx| {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_traits/normalize_projection_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ use rustc::traits::{self, FulfillmentContext, Normalized, ObligationCause,
use rustc::traits::query::{CanonicalProjectionGoal, NoSolution, normalize::NormalizationResult};
use rustc::ty::{ParamEnvAnd, TyCtxt};
use rustc::util::common::CellUsizeExt;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;
use syntax::ast::DUMMY_NODE_ID;
use syntax_pos::DUMMY_SP;
use util;

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

tcx.sess.perf_stats.normalize_projection_ty.increment();
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

Loading