Const eval asserts that reporting an error for statics actually worked. This is not only done in a wrong way (checks for no error having happened in the entire compilation), it's also very fragile. We should instead use the track_errors method around the report_as_error call, and in case track_errors returns Ok, we need to do the delay_span_bug.
The relevant code that needs to be changed can be found in
|
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, |
|
&format!("static eval failure did not emit an error: {:#?}", |
|
reported_err)); |
|
} |
|
reported_err |
Const eval asserts that reporting an error for statics actually worked. This is not only done in a wrong way (checks for no error having happened in the entire compilation), it's also very fragile. We should instead use the
track_errorsmethod around thereport_as_errorcall, and in casetrack_errorsreturnsOk, we need to do thedelay_span_bug.The relevant code that needs to be changed can be found in
rust/src/librustc_mir/const_eval.rs
Lines 645 to 654 in 16e7e05