Skip to content

Commit 9a9dbff

Browse files
committed
vtables are not leaks
1 parent 3fb617d commit 9a9dbff

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/librustc_mir/interpret/memory.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
584584

585585
pub fn leak_report(&self) -> usize {
586586
trace!("### LEAK REPORT ###");
587-
let static_kind = M::STATIC_KIND.map(|k| MemoryKind::Machine(k));
588-
let leaks: Vec<_> = self.alloc_map.filter_map_collect(|&id, &(kind, _)|
589-
// exclude mutable statics
590-
if Some(kind) == static_kind { None } else { Some(id) } );
587+
let leaks: Vec<_> = self.alloc_map.filter_map_collect(|&id, &(kind, _)| {
588+
// exclude statics and vtables
589+
let exclude = match kind {
590+
MemoryKind::Stack => false,
591+
MemoryKind::Vtable => true,
592+
MemoryKind::Machine(k) => Some(k) == M::STATIC_KIND,
593+
};
594+
if exclude { None } else { Some(id) }
595+
});
591596
let n = leaks.len();
592597
self.dump_allocs(leaks);
593598
n

0 commit comments

Comments
 (0)