From 7b5981aad4431f04c8c599d80d9a21d50d680ae1 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Dec 2017 14:19:57 +0000 Subject: [PATCH] Fix division-by-zero ICE in -Z perf-stats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An invalid average now simply prints “N/A”. Fixes #46725. --- src/librustc/session/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 36c1966bdc8..85e24b16752 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -635,9 +635,13 @@ impl Session { self.perf_stats.incr_comp_hashes_count.get()); println!("Total number of bytes hashed for incr. comp.: {}", self.perf_stats.incr_comp_bytes_hashed.get()); - println!("Average bytes hashed per incr. comp. HIR node: {}", - self.perf_stats.incr_comp_bytes_hashed.get() / - self.perf_stats.incr_comp_hashes_count.get()); + if self.perf_stats.incr_comp_hashes_count.get() != 0 { + println!("Average bytes hashed per incr. comp. HIR node: {}", + self.perf_stats.incr_comp_bytes_hashed.get() / + self.perf_stats.incr_comp_hashes_count.get()); + } else { + println!("Average bytes hashed per incr. comp. HIR node: N/A"); + } println!("Total time spent computing symbol hashes: {}", duration_to_secs_str(self.perf_stats.symbol_hash_time.get())); println!("Total time spent decoding DefPath tables: {}",