From 3ba7454152e65beb7519580d8f74cf433f20b724 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Fri, 22 Mar 2019 04:38:22 +0900 Subject: [PATCH] Use track_errors --- src/librustc_mir/const_eval.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 6ab89f80ef52..0cf6c4593e8d 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -645,10 +645,14 @@ pub fn const_eval_raw_provider<'a, '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 errs = tcx.sess.track_errors(|| { + tcx.sess.err_count(); + }); + match errs { + Ok(_) => tcx.sess.delay_span_bug(err.span, &format!("static eval failure did not emit an error: {:#?}", - reported_err)); + reported_err)), + Err(_) => (), } reported_err } else if def_id.is_local() {