diff options
| author | Ralf Jung <post@ralfj.de> | 2024-11-18 08:42:42 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-11-18 20:48:03 +0100 |
| commit | c6974344a5707c054ed808ea9c724dd93ec3c680 (patch) | |
| tree | 19a084178f1325d2e252df447af7bd3e3b7a163d /compiler/rustc_const_eval/src/const_eval | |
| parent | 3fb7e441aecc3c054d71eb4d752d06e7776e8888 (diff) | |
| download | rust-c6974344a5707c054ed808ea9c724dd93ec3c680.tar.gz rust-c6974344a5707c054ed808ea9c724dd93ec3c680.zip | |
interpret: do not ICE when a promoted fails with OOM
Diffstat (limited to 'compiler/rustc_const_eval/src/const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/error.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index 6686413bf02..1271d9d2d0d 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -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) } } } |
