about summary refs log tree commit diff
path: root/compiler/rustc_middle
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-11-19 13:24:09 +0000
committerbors <bors@rust-lang.org>2024-11-19 13:24:09 +0000
commit89b688552994bd8404b8fdab2cf96f00632af0ff (patch)
treee66f3e72be73c84a7655663acdd1ba4a4d9a4a13 /compiler/rustc_middle
parent7d40450b2df92bdc9dec414b30cf5f7a5979a92e (diff)
parentc6974344a5707c054ed808ea9c724dd93ec3c680 (diff)
downloadrust-89b688552994bd8404b8fdab2cf96f00632af0ff.tar.gz
rust-89b688552994bd8404b8fdab2cf96f00632af0ff.zip
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
Diffstat (limited to 'compiler/rustc_middle')
-rw-r--r--compiler/rustc_middle/src/mir/interpret/error.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs
index 8ec7e1851a5..08afa33c6b4 100644
--- a/compiler/rustc_middle/src/mir/interpret/error.rs
+++ b/compiler/rustc_middle/src/mir/interpret/error.rs
@@ -59,22 +59,33 @@ impl ErrorHandled {
 pub struct ReportedErrorInfo {
     error: ErrorGuaranteed,
     is_tainted_by_errors: bool,
+    /// Whether this is the kind of error that can sometimes occur, and sometimes not.
+    /// Used for resource exhaustion errors.
+    can_be_spurious: bool,
 }
 
 impl ReportedErrorInfo {
     #[inline]
     pub fn tainted_by_errors(error: ErrorGuaranteed) -> ReportedErrorInfo {
-        ReportedErrorInfo { is_tainted_by_errors: true, error }
+        ReportedErrorInfo { is_tainted_by_errors: true, can_be_spurious: false, error }
     }
+    #[inline]
+    pub fn spurious(error: ErrorGuaranteed) -> ReportedErrorInfo {
+        ReportedErrorInfo { can_be_spurious: true, is_tainted_by_errors: false, error }
+    }
+
     pub fn is_tainted_by_errors(&self) -> bool {
         self.is_tainted_by_errors
     }
+    pub fn can_be_spurious(&self) -> bool {
+        self.can_be_spurious
+    }
 }
 
 impl From<ErrorGuaranteed> for ReportedErrorInfo {
     #[inline]
     fn from(error: ErrorGuaranteed) -> ReportedErrorInfo {
-        ReportedErrorInfo { is_tainted_by_errors: false, error }
+        ReportedErrorInfo { is_tainted_by_errors: false, can_be_spurious: false, error }
     }
 }