about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-11-25 18:41:53 +0100
committerRalf Jung <post@ralfj.de>2023-12-07 17:46:36 +0100
commit994d36bac0478b54effef82d2d40859b227d6def (patch)
tree5a2fbc44942ab83835f33bab93b1769185353b0f
parent400cd47c288a273a38d63eb88d15d54dc72fbbbb (diff)
downloadrust-994d36bac0478b54effef82d2d40859b227d6def.tar.gz
rust-994d36bac0478b54effef82d2d40859b227d6def.zip
ctfe interpreter: extend provenance so that it can track whether a pointer is immutable
-rw-r--r--src/constant.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/constant.rs b/src/constant.rs
index cf68a3857c5..65f7ee6999a 100644
--- a/src/constant.rs
+++ b/src/constant.rs
@@ -126,7 +126,8 @@ pub(crate) fn codegen_const_value<'tcx>(
                 }
             }
             Scalar::Ptr(ptr, _size) => {
-                let (alloc_id, offset) = ptr.into_parts(); // we know the `offset` is relative
+                let (prov, offset) = ptr.into_parts(); // we know the `offset` is relative
+                let alloc_id = prov.alloc_id();
                 let base_addr = match fx.tcx.global_alloc(alloc_id) {
                     GlobalAlloc::Memory(alloc) => {
                         let data_id = data_id_for_alloc_id(
@@ -374,7 +375,8 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
         let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec();
         data.define(bytes.into_boxed_slice());
 
-        for &(offset, alloc_id) in alloc.provenance().ptrs().iter() {
+        for &(offset, prov) in alloc.provenance().ptrs().iter() {
+            let alloc_id = prov.alloc_id();
             let addend = {
                 let endianness = tcx.data_layout.endian;
                 let offset = offset.bytes() as usize;