From 9a9dbfff6e0622e69cb37ba0cda919f619dad1cd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 5 Oct 2018 18:08:36 +0200 Subject: vtables are not leaks --- src/librustc_mir/interpret/memory.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index c8777bb9a98..d9226e7464b 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -584,10 +584,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { pub fn leak_report(&self) -> usize { trace!("### LEAK REPORT ###"); - let static_kind = M::STATIC_KIND.map(|k| MemoryKind::Machine(k)); - let leaks: Vec<_> = self.alloc_map.filter_map_collect(|&id, &(kind, _)| - // exclude mutable statics - if Some(kind) == static_kind { None } else { Some(id) } ); + let leaks: Vec<_> = self.alloc_map.filter_map_collect(|&id, &(kind, _)| { + // exclude statics and vtables + let exclude = match kind { + MemoryKind::Stack => false, + MemoryKind::Vtable => true, + MemoryKind::Machine(k) => Some(k) == M::STATIC_KIND, + }; + if exclude { None } else { Some(id) } + }); let n = leaks.len(); self.dump_allocs(leaks); n -- cgit 1.4.1-3-g733a5