interpret: do not ICE when a promoted fails with OOM
This commit is contained in:
parent
3fb7e441ae
commit
c6974344a5
6 changed files with 51 additions and 7 deletions
|
@ -152,13 +152,20 @@ where
|
|||
let span = span.substitute_dummy(our_span);
|
||||
let err = mk(span, frames);
|
||||
let mut err = tcx.dcx().create_err(err);
|
||||
let can_be_spurious = matches!(error, InterpErrorKind::ResourceExhaustion(_));
|
||||
|
||||
let msg = error.diagnostic_message();
|
||||
error.add_args(&mut err);
|
||||
|
||||
// Use *our* span to label the interp error
|
||||
err.span_label(our_span, msg);
|
||||
ErrorHandled::Reported(err.emit().into(), span)
|
||||
let g = err.emit();
|
||||
let reported = if can_be_spurious {
|
||||
ReportedErrorInfo::spurious(g)
|
||||
} else {
|
||||
ReportedErrorInfo::from(g)
|
||||
};
|
||||
ErrorHandled::Reported(reported, span)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -596,6 +596,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||
// const-eval will return "tainted" errors if e.g. the layout cannot
|
||||
// be computed as the type references non-existing names.
|
||||
// See <https://github.com/rust-lang/rust/issues/124348>.
|
||||
} else if reported.can_be_spurious() {
|
||||
// These errors can just sometimes happen, even when the expression
|
||||
// is nominally "infallible", e.g. when running out of memory.
|
||||
} else {
|
||||
// Looks like the const is not captured by `required_consts`, that's bad.
|
||||
span_bug!(span, "interpret const eval failure of {val:?} which is not in required_consts");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue