diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-03-29 02:40:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-29 02:40:46 +0100 |
| commit | 97927da0485800a3f2ba3f32185be301ce103ef6 (patch) | |
| tree | cfe2a247955f97f7e34a3802758acdbdff2b650f /src | |
| parent | 8794e21ff329d1201d484c015d48e85490a64fa9 (diff) | |
| parent | 07788478332d645293a81686d5d225b8aafabe90 (diff) | |
| download | rust-97927da0485800a3f2ba3f32185be301ce103ef6.tar.gz rust-97927da0485800a3f2ba3f32185be301ce103ef6.zip | |
Rollup merge of #59358 - JohnTitor:use-track-errors, r=oli-obk
Use `track_errors` instead of hand rolling Fixes #59215 r? @oli-obk
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/const_eval.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 6ab89f80ef5..2268568c5f8 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -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; @@ -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) { |
