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 @@ pub fn reserve_alloc_id(self) -> AllocId { 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(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!