about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2025-08-23 22:22:17 +0200
committerGitHub <noreply@github.com>2025-08-23 22:22:17 +0200
commit95f8b919e6f6d1a8c8eb7e8fad298ef706aae65f (patch)
treef0bc3464370edb97ec77dd74284ae3a2448fd8aa /compiler
parent1b9ae8f408d37882ba3ff17851c30d6dc26f5b47 (diff)
parent7046ce89c666bb9e8695eb9b92721156c7b2b0ec (diff)
downloadrust-95f8b919e6f6d1a8c8eb7e8fad298ef706aae65f.tar.gz
rust-95f8b919e6f6d1a8c8eb7e8fad298ef706aae65f.zip
Rollup merge of #145540 - nia-e:prov-map-range, r=RalfJung
interpret/allocation: get_range on ProvenanceMap

Helper method to grab all provenances in a given address range for an allocation, making some logic in Miri nicer.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs
index ea8596ea286..dbbd95408c8 100644
--- a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs
+++ b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs
@@ -120,6 +120,17 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
         }
     }
 
+    /// Gets the provenances of all bytes (including from pointers) in a range.
+    pub fn get_range(
+        &self,
+        cx: &impl HasDataLayout,
+        range: AllocRange,
+    ) -> impl Iterator<Item = Prov> {
+        let ptr_provs = self.range_ptrs_get(range, cx).iter().map(|(_, p)| *p);
+        let byte_provs = self.range_bytes_get(range).iter().map(|(_, (p, _))| *p);
+        ptr_provs.chain(byte_provs)
+    }
+
     /// Attempt to merge per-byte provenance back into ptr chunks, if the right fragments
     /// sit next to each other. Return `false` is that is not possible due to partial pointers.
     pub fn merge_bytes(&mut self, cx: &impl HasDataLayout) -> bool {