about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-16 15:15:54 +0000
committerbors <bors@rust-lang.org>2023-11-16 15:15:54 +0000
commit0ea7ddcc35a2fcaa5da8a7dcfc118c9fb4a63b95 (patch)
treed29e1009311d376d16efff49e572aa97eb0e255e
parent1be1e84872185c427de42f4d9e757d3e3e28d90e (diff)
parentd7cecd3db24e3905a39f458e9202016a5685579a (diff)
downloadrust-0ea7ddcc35a2fcaa5da8a7dcfc118c9fb4a63b95.tar.gz
rust-0ea7ddcc35a2fcaa5da8a7dcfc118c9fb4a63b95.zip
Auto merge of #117956 - saethlin:provenance-gc-access, r=RalfJung
Let Miri see the AllocId for all TyCtxt allocations

Per https://github.com/rust-lang/miri/pull/3103#discussion_r1391589896

r? `@RalfJung`
-rw-r--r--compiler/rustc_middle/src/mir/interpret/mod.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs
index e360fb3eaaf..b87c6885e04 100644
--- a/compiler/rustc_middle/src/mir/interpret/mod.rs
+++ b/compiler/rustc_middle/src/mir/interpret/mod.rs
@@ -525,6 +525,13 @@ impl<'tcx> TyCtxt<'tcx> {
         self.alloc_map.lock().reserve()
     }
 
+    /// Miri's provenance GC needs to see all live allocations. The interpreter manages most
+    /// allocations but some are managed by [`TyCtxt`] and without this method the interpreter
+    /// doesn't know their [`AllocId`]s are in use.
+    pub fn iter_allocs<F: FnMut(AllocId)>(self, func: F) {
+        self.alloc_map.lock().alloc_map.keys().copied().for_each(func)
+    }
+
     /// Reserves a new ID *if* this allocation has not been dedup-reserved before.
     /// Should only be used for "symbolic" allocations (function pointers, vtables, statics), we
     /// don't want to dedup IDs for "real" memory!