1
Fork 0

Auto merge of #133164 - RalfJung:promoted-oom, r=jieyouxu

interpret: do not ICE when a promoted fails with OOM

Fixes https://github.com/rust-lang/rust/issues/130687

try-job: aarch64-apple
try-job: dist-x86_64-linux
This commit is contained in:
bors 2024-11-19 13:24:09 +00:00
commit 89b6885529
6 changed files with 51 additions and 7 deletions

View file

@ -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)
}
}
}