Skip to content

Commit

Permalink
Rollup merge of rust-lang#59358 - JohnTitor:use-track-errors, r=oli-obk
Browse files Browse the repository at this point in the history
Use `track_errors` instead of hand rolling

Fixes rust-lang#59215

r? @oli-obk
  • Loading branch information
Centril authored Mar 29, 2019
2 parents 8794e21 + 0778847 commit 97927da
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/librustc_mir/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use rustc::ty::{self, TyCtxt, query::TyCtxtAt};
use rustc::ty::layout::{self, LayoutOf, VariantIdx};
use rustc::ty::subst::Subst;
use rustc::traits::Reveal;
use rustc::util::common::ErrorReported;
use rustc_data_structures::fx::FxHashMap;

use syntax::ast::Mutability;
Expand Down Expand Up @@ -641,16 +642,21 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
let err = error_to_const_error(&ecx, error);
// errors in statics are always emitted as fatal errors
if tcx.is_static(def_id).is_some() {
let reported_err = err.report_as_error(ecx.tcx,
"could not evaluate static initializer");
// Ensure that if the above error was either `TooGeneric` or `Reported`
// an error must be reported.
if tcx.sess.err_count() == 0 {
tcx.sess.delay_span_bug(err.span,
let reported_err = tcx.sess.track_errors(|| {
err.report_as_error(ecx.tcx,
"could not evaluate static initializer")
});
match reported_err {
Ok(v) => {
tcx.sess.delay_span_bug(err.span,
&format!("static eval failure did not emit an error: {:#?}",
reported_err));
v));
v
},
Err(ErrorReported) => ErrorHandled::Reported,
}
reported_err
} else if def_id.is_local() {
// constant defined in this crate, we can figure out a lint level!
match tcx.describe_def(def_id) {
Expand Down

0 comments on commit 97927da

Please sign in to comment.