@@ -293,21 +293,29 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
293
293
}
294
294
295
295
/// Call this when all units are finished.
296
- pub fn finished ( & mut self , bcx : & BuildContext < ' _ , ' _ > ) -> CargoResult < ( ) > {
296
+ pub fn finished (
297
+ & mut self ,
298
+ bcx : & BuildContext < ' _ , ' _ > ,
299
+ error : & Option < anyhow:: Error > ,
300
+ ) -> CargoResult < ( ) > {
297
301
if !self . enabled {
298
302
return Ok ( ( ) ) ;
299
303
}
300
304
self . mark_concurrency ( 0 , 0 , 0 , 0 ) ;
301
305
self . unit_times
302
306
. sort_unstable_by ( |a, b| a. start . partial_cmp ( & b. start ) . unwrap ( ) ) ;
303
307
if self . report_html {
304
- self . report_html ( bcx) ?;
308
+ self . report_html ( bcx, error ) ?;
305
309
}
306
310
Ok ( ( ) )
307
311
}
308
312
309
313
/// Save HTML report to disk.
310
- fn report_html ( & self , bcx : & BuildContext < ' _ , ' _ > ) -> CargoResult < ( ) > {
314
+ fn report_html (
315
+ & self ,
316
+ bcx : & BuildContext < ' _ , ' _ > ,
317
+ error : & Option < anyhow:: Error > ,
318
+ ) -> CargoResult < ( ) > {
311
319
let duration = d_as_f64 ( self . start . elapsed ( ) ) ;
312
320
let timestamp = self . start_str . replace ( & [ '-' , ':' ] [ ..] , "" ) ;
313
321
let filename = format ! ( "cargo-timing-{}.html" , timestamp) ;
@@ -318,7 +326,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
318
326
. map ( |( name, _targets) | name. as_str ( ) )
319
327
. collect ( ) ;
320
328
f. write_all ( HTML_TMPL . replace ( "{ROOTS}" , & roots. join ( ", " ) ) . as_bytes ( ) ) ?;
321
- self . write_summary_table ( & mut f, duration, bcx) ?;
329
+ self . write_summary_table ( & mut f, duration, bcx, error ) ?;
322
330
f. write_all ( HTML_CANVAS . as_bytes ( ) ) ?;
323
331
self . write_unit_table ( & mut f) ?;
324
332
// It helps with pixel alignment to use whole numbers.
@@ -359,6 +367,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
359
367
f : & mut impl Write ,
360
368
duration : f64 ,
361
369
bcx : & BuildContext < ' _ , ' _ > ,
370
+ error : & Option < anyhow:: Error > ,
362
371
) -> CargoResult < ( ) > {
363
372
let targets: Vec < String > = self
364
373
. root_targets
@@ -380,6 +389,17 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
380
389
. max ( )
381
390
. unwrap ( ) ;
382
391
let rustc_info = render_rustc_info ( bcx) ;
392
+ let error_msg = match error {
393
+ Some ( e) => format ! (
394
+ r#"\
395
+ <tr>
396
+ <td class="error-text">Error:</td><td>{}</td>
397
+ </tr>
398
+ "# ,
399
+ e
400
+ ) ,
401
+ None => "" . to_string ( ) ,
402
+ } ;
383
403
write ! (
384
404
f,
385
405
r#"
@@ -414,7 +434,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
414
434
<tr>
415
435
<td>Max (global) rustc threads concurrency:</td><td>{}</td>
416
436
</tr>
417
-
437
+ {}
418
438
</table>
419
439
"# ,
420
440
targets,
@@ -429,6 +449,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
429
449
total_time,
430
450
rustc_info,
431
451
max_rustc_concurrency,
452
+ error_msg,
432
453
) ?;
433
454
Ok ( ( ) )
434
455
}
@@ -698,6 +719,10 @@ h1 {
698
719
text-align: center;
699
720
}
700
721
722
+ .error-text {
723
+ color: #e80000;
724
+ }
725
+
701
726
</style>
702
727
</head>
703
728
<body>
0 commit comments