about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/interpret
diff options
context:
space:
mode:
authorSmitty <me@smitop.com>2021-07-02 16:06:12 -0400
committerSmitty <me@smitop.com>2021-07-02 16:06:12 -0400
commite9d69d9f8eb888a6e124c567f804c2e464c7b00a (patch)
treecda4f0d2606eec333af0c4eba1a9e1962847ea6e /compiler/rustc_mir/src/interpret
parent3e20129a18b34ba3aa13efaa53ddfa09dfb1fb7b (diff)
downloadrust-e9d69d9f8eb888a6e124c567f804c2e464c7b00a.tar.gz
rust-e9d69d9f8eb888a6e124c567f804c2e464c7b00a.zip
Allocation failure in constprop panics right away
Diffstat (limited to 'compiler/rustc_mir/src/interpret')
-rw-r--r--compiler/rustc_mir/src/interpret/machine.rs3
-rw-r--r--compiler/rustc_mir/src/interpret/memory.rs2
2 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_mir/src/interpret/machine.rs b/compiler/rustc_mir/src/interpret/machine.rs
index 0d01dc3c219..5b8c0788cbc 100644
--- a/compiler/rustc_mir/src/interpret/machine.rs
+++ b/compiler/rustc_mir/src/interpret/machine.rs
@@ -122,6 +122,9 @@ pub trait Machine<'mir, 'tcx>: Sized {
     /// that is added to the memory so that the work is not done twice.
     const GLOBAL_KIND: Option<Self::MemoryKind>;
 
+    /// Should the machine panic on allocation failures?
+    const PANIC_ON_ALLOC_FAIL: bool;
+
     /// Whether memory accesses should be alignment-checked.
     fn enforce_alignment(memory_extra: &Self::MemoryExtra) -> bool;
 
diff --git a/compiler/rustc_mir/src/interpret/memory.rs b/compiler/rustc_mir/src/interpret/memory.rs
index 671e3d278f3..cb929c21850 100644
--- a/compiler/rustc_mir/src/interpret/memory.rs
+++ b/compiler/rustc_mir/src/interpret/memory.rs
@@ -208,7 +208,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
         align: Align,
         kind: MemoryKind<M::MemoryKind>,
     ) -> InterpResult<'static, Pointer<M::PointerTag>> {
-        let alloc = Allocation::uninit(size, align)?;
+        let alloc = Allocation::uninit(size, align, M::PANIC_ON_ALLOC_FAIL)?;
         Ok(self.allocate_with(alloc, kind))
     }