From 15d8e06a44d1037ce3553b2a5e971165cb98ea69 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 3 Aug 2020 23:27:27 -0400 Subject: [PATCH] Don't blow up on module timings if there was an error --- compiler/load/src/file.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index f434582c08..1601488508 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -191,19 +191,20 @@ impl ModuleTiming { end_time .duration_since(*start_time) - .unwrap() - .checked_sub(*solve) - .unwrap() - .checked_sub(*constrain) - .unwrap() - .checked_sub(*canonicalize) - .unwrap() - .checked_sub(*parse_body) - .unwrap() - .checked_sub(*parse_header) - .unwrap() - .checked_sub(*read_roc_file) - .unwrap() + .ok() + .and_then(|t| { + t.checked_sub(*solve).and_then(|t| { + t.checked_sub(*constrain).and_then(|t| { + t.checked_sub(*canonicalize).and_then(|t| { + t.checked_sub(*parse_body).and_then(|t| { + t.checked_sub(*parse_header) + .and_then(|t| t.checked_sub(*read_roc_file)) + }) + }) + }) + }) + }) + .unwrap_or_else(Duration::default) } }