diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 9f73c2aa06e..964f7215088 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -641,19 +641,17 @@ 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. - let tracked_err = tcx.sess.track_errors(|| { + let reported_err = tcx.sess.track_errors(|| { err.report_as_error(ecx.tcx, "could not evaluate static initializer"); }); - match tracked_err { - Ok(reported_err) => tcx.sess.delay_span_bug(err.span, + match reported_err { + Ok(v) => tcx.sess.delay_span_bug(err.span, &format!("static eval failure did not emit an error: {:#?}", - reported_err)), - Err(_) => (), + v)), + Err(err) => err, } reported_err } else if def_id.is_local() {