about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret/memory.rs
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2025-07-10 17:54:55 +0800
committerDeadbeef <ent3rm4n@gmail.com>2025-07-16 00:32:12 +0800
commit44b38ca45edc4bd826f4ef5e3fb2221cbd1649cd (patch)
tree4c8b2465c1f9f4838de0808bac24e7f196a79077 /compiler/rustc_const_eval/src/interpret/memory.rs
parent3f2dc2bd1a2e0120b868911497ddbd8e43f3a9fa (diff)
downloadrust-44b38ca45edc4bd826f4ef5e3fb2221cbd1649cd.tar.gz
rust-44b38ca45edc4bd826f4ef5e3fb2221cbd1649cd.zip
format pointer later instead of eagerly converting to string
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/memory.rs')
-rw-r--r--compiler/rustc_const_eval/src/interpret/memory.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs
index 50578e13a7a..08682dd193d 100644
--- a/compiler/rustc_const_eval/src/interpret/memory.rs
+++ b/compiler/rustc_const_eval/src/interpret/memory.rs
@@ -315,33 +315,33 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
     /// mark the `const_allocate`d pointer immutable so we can intern it.
     pub fn make_const_heap_ptr_global(
         &mut self,
-        ptr: Pointer<Option<M::Provenance>>,
+        ptr: Pointer<Option<CtfeProvenance>>,
     ) -> InterpResult<'tcx>
     where
-        M: Machine<'tcx, MemoryKind = crate::const_eval::MemoryKind>,
+        M: Machine<'tcx, MemoryKind = crate::const_eval::MemoryKind, Provenance = CtfeProvenance>,
     {
         let (alloc_id, offset, _) = self.ptr_get_alloc_id(ptr, 0)?;
         if offset.bytes() != 0 {
-            return Err(ConstEvalErrKind::ConstMakeGlobalWithOffset(format!("{ptr:?}"))).into();
+            return Err(ConstEvalErrKind::ConstMakeGlobalWithOffset(ptr)).into();
         }
 
         let not_local_heap =
             matches!(self.tcx.try_get_global_alloc(alloc_id), Some(GlobalAlloc::Memory(_)));
 
         if not_local_heap {
-            return Err(ConstEvalErrKind::ConstMakeGlobalPtrIsNonHeap(format!("{ptr:?}"))).into();
+            return Err(ConstEvalErrKind::ConstMakeGlobalPtrIsNonHeap(ptr)).into();
         }
 
-        let (kind, alloc) = self.memory.alloc_map.get_mut_or(alloc_id, || {
-            Err(ConstEvalErrKind::ConstMakeGlobalWithDanglingPtr(format!("{ptr:?}")))
-        })?;
+        let (kind, alloc) = self
+            .memory
+            .alloc_map
+            .get_mut_or(alloc_id, || Err(ConstEvalErrKind::ConstMakeGlobalWithDanglingPtr(ptr)))?;
 
         alloc.mutability = Mutability::Not;
 
         match kind {
             MemoryKind::Stack | MemoryKind::CallerLocation => {
-                return Err(ConstEvalErrKind::ConstMakeGlobalPtrIsNonHeap(format!("{ptr:?}")))
-                    .into();
+                return Err(ConstEvalErrKind::ConstMakeGlobalPtrIsNonHeap(ptr)).into();
             }
             MemoryKind::Machine(crate::const_eval::MemoryKind::Heap { was_made_global }) => {
                 if *was_made_global {