Skip to content

Commit 0ea7ddc

Browse files
committed
Auto merge of #117956 - saethlin:provenance-gc-access, r=RalfJung
Let Miri see the AllocId for all TyCtxt allocations Per rust-lang/miri#3103 (comment) r? `@RalfJung`
2 parents 1be1e84 + d7cecd3 commit 0ea7ddc

File tree

1 file changed

+7
-0
lines changed
  • compiler/rustc_middle/src/mir/interpret

1 file changed

+7
-0
lines changed

compiler/rustc_middle/src/mir/interpret/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,13 @@ impl<'tcx> TyCtxt<'tcx> {
525525
self.alloc_map.lock().reserve()
526526
}
527527

528+
/// Miri's provenance GC needs to see all live allocations. The interpreter manages most
529+
/// allocations but some are managed by [`TyCtxt`] and without this method the interpreter
530+
/// doesn't know their [`AllocId`]s are in use.
531+
pub fn iter_allocs<F: FnMut(AllocId)>(self, func: F) {
532+
self.alloc_map.lock().alloc_map.keys().copied().for_each(func)
533+
}
534+
528535
/// Reserves a new ID *if* this allocation has not been dedup-reserved before.
529536
/// Should only be used for "symbolic" allocations (function pointers, vtables, statics), we
530537
/// don't want to dedup IDs for "real" memory!

0 commit comments

Comments
 (0)