diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_mir/src/interpret/intern.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/interpret/intrinsics.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/interpret/memory.rs | 6 |
3 files changed, 12 insertions, 6 deletions
diff --git a/compiler/rustc_mir/src/interpret/intern.rs b/compiler/rustc_mir/src/interpret/intern.rs index 443ef072647..db996f72128 100644 --- a/compiler/rustc_mir/src/interpret/intern.rs +++ b/compiler/rustc_mir/src/interpret/intern.rs @@ -104,7 +104,10 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>( // This match is just a canary for future changes to `MemoryKind`, which most likely need // changes in this function. match kind { - MemoryKind::Stack | MemoryKind::Heap | MemoryKind::Vtable | MemoryKind::CallerLocation => {} + MemoryKind::Stack + | MemoryKind::ConstHeap + | MemoryKind::Vtable + | MemoryKind::CallerLocation => {} } // Set allocation mutability as appropriate. This is used by LLVM to put things into // read-only memory, and also by Miri when evaluating other globals that diff --git a/compiler/rustc_mir/src/interpret/intrinsics.rs b/compiler/rustc_mir/src/interpret/intrinsics.rs index 4bc263730c3..84a53a589a5 100644 --- a/compiler/rustc_mir/src/interpret/intrinsics.rs +++ b/compiler/rustc_mir/src/interpret/intrinsics.rs @@ -347,8 +347,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { Err(err) => throw_ub_format!("align has to be a power of 2, {}", err), }; - let ptr = - self.memory.allocate(Size::from_bytes(size as u64), align, MemoryKind::Heap); + let ptr = self.memory.allocate( + Size::from_bytes(size as u64), + align, + MemoryKind::ConstHeap, + ); self.write_scalar(Scalar::Ptr(ptr), dest)?; } sym::offset => { diff --git a/compiler/rustc_mir/src/interpret/memory.rs b/compiler/rustc_mir/src/interpret/memory.rs index 1319ecd5b2e..47d0fce51b1 100644 --- a/compiler/rustc_mir/src/interpret/memory.rs +++ b/compiler/rustc_mir/src/interpret/memory.rs @@ -28,7 +28,7 @@ pub enum MemoryKind<T> { /// Stack memory. Error if deallocated except during a stack pop. Stack, /// Heap memory. - Heap, + ConstHeap, /// Memory backing vtables. Error if ever deallocated. Vtable, /// Memory allocated by `caller_location` intrinsic. Error if ever deallocated. @@ -42,7 +42,7 @@ impl<T: MayLeak> MayLeak for MemoryKind<T> { fn may_leak(self) -> bool { match self { MemoryKind::Stack => false, - MemoryKind::Heap => false, + MemoryKind::ConstHeap => false, MemoryKind::Vtable => true, MemoryKind::CallerLocation => true, MemoryKind::Machine(k) => k.may_leak(), @@ -54,7 +54,7 @@ impl<T: fmt::Display> fmt::Display for MemoryKind<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { MemoryKind::Stack => write!(f, "stack variable"), - MemoryKind::Heap => write!(f, "heap allocation"), + MemoryKind::ConstHeap => write!(f, "heap allocation"), MemoryKind::Vtable => write!(f, "vtable"), MemoryKind::CallerLocation => write!(f, "caller location"), MemoryKind::Machine(m) => write!(f, "{}", m), |
