diff --git a/src/cargo/core/compiler/job_queue.rs b/src/cargo/core/compiler/job_queue.rs index 55954911718..d70571ac746 100644 --- a/src/cargo/core/compiler/job_queue.rs +++ b/src/cargo/core/compiler/job_queue.rs @@ -676,6 +676,7 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> { } let time_elapsed = util::elapsed(cx.bcx.config.creation_time().elapsed()); + self.timings.finished(cx.bcx, &error)?; if let Some(e) = error { Err(e) @@ -687,7 +688,6 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> { if !cx.bcx.build_config.build_plan { cx.bcx.config.shell().status("Finished", message)?; } - self.timings.finished(cx.bcx)?; Ok(()) } else { debug!("queue: {:#?}", self.queue); diff --git a/src/cargo/core/compiler/timings.rs b/src/cargo/core/compiler/timings.rs index ff24e77b10a..e8bdac83e4a 100644 --- a/src/cargo/core/compiler/timings.rs +++ b/src/cargo/core/compiler/timings.rs @@ -293,7 +293,11 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { } /// Call this when all units are finished. - pub fn finished(&mut self, bcx: &BuildContext<'_, '_>) -> CargoResult<()> { + pub fn finished( + &mut self, + bcx: &BuildContext<'_, '_>, + error: &Option, + ) -> CargoResult<()> { if !self.enabled { return Ok(()); } @@ -301,13 +305,17 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { self.unit_times .sort_unstable_by(|a, b| a.start.partial_cmp(&b.start).unwrap()); if self.report_html { - self.report_html(bcx)?; + self.report_html(bcx, error)?; } Ok(()) } /// Save HTML report to disk. - fn report_html(&self, bcx: &BuildContext<'_, '_>) -> CargoResult<()> { + fn report_html( + &self, + bcx: &BuildContext<'_, '_>, + error: &Option, + ) -> CargoResult<()> { let duration = d_as_f64(self.start.elapsed()); let timestamp = self.start_str.replace(&['-', ':'][..], ""); let filename = format!("cargo-timing-{}.html", timestamp); @@ -318,7 +326,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { .map(|(name, _targets)| name.as_str()) .collect(); f.write_all(HTML_TMPL.replace("{ROOTS}", &roots.join(", ")).as_bytes())?; - self.write_summary_table(&mut f, duration, bcx)?; + self.write_summary_table(&mut f, duration, bcx, error)?; f.write_all(HTML_CANVAS.as_bytes())?; self.write_unit_table(&mut f)?; // It helps with pixel alignment to use whole numbers. @@ -359,6 +367,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { f: &mut impl Write, duration: f64, bcx: &BuildContext<'_, '_>, + error: &Option, ) -> CargoResult<()> { let targets: Vec = self .root_targets @@ -380,6 +389,17 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { .max() .unwrap(); let rustc_info = render_rustc_info(bcx); + let error_msg = match error { + Some(e) => format!( + r#"\ + + Error:{} + +"#, + e + ), + None => "".to_string(), + }; write!( f, r#" @@ -414,7 +434,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { Max (global) rustc threads concurrency:{} - +{} "#, targets, @@ -429,6 +449,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { total_time, rustc_info, max_rustc_concurrency, + error_msg, )?; Ok(()) } @@ -698,6 +719,10 @@ h1 { text-align: center; } +.error-text { + color: #e80000; +} +