about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2018-10-05 18:08:36 +0200
committerRalf Jung <post@ralfj.de>2018-10-10 10:11:35 +0200
commit9a9dbfff6e0622e69cb37ba0cda919f619dad1cd (patch)
tree9c7c0c7bba082d11342ba093f12dd8020e4016b0 /src
parent3fb617d0c5d0f8991aea5be29c9adda19bbd24a5 (diff)
vtables are not leaks
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/interpret/memory.rs13
1 files changed, 9 insertions, 4 deletions
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