@@ -1530,13 +1530,16 @@ impl DiagCtxtInner {
1530
1530
1531
1531
fn flush_delayed (
1532
1532
& mut self ,
1533
- bugs : impl IntoIterator < Item = DelayedDiagnostic > ,
1533
+ bugs : Vec < DelayedDiagnostic > ,
1534
1534
explanation : impl Into < DiagnosticMessage > + Copy ,
1535
1535
) {
1536
- let mut no_bugs = true ;
1536
+ if bugs. is_empty ( ) {
1537
+ return ;
1538
+ }
1539
+
1537
1540
// If backtraces are enabled, also print the query stack
1538
1541
let backtrace = std:: env:: var_os ( "RUST_BACKTRACE" ) . map_or ( true , |x| & x != "0" ) ;
1539
- for bug in bugs {
1542
+ for ( i , bug) in bugs. into_iter ( ) . enumerate ( ) {
1540
1543
if let Some ( file) = self . ice_file . as_ref ( )
1541
1544
&& let Ok ( mut out) = std:: fs:: File :: options ( ) . create ( true ) . append ( true ) . open ( file)
1542
1545
{
@@ -1551,16 +1554,16 @@ impl DiagCtxtInner {
1551
1554
& bug. note
1552
1555
) ;
1553
1556
}
1554
- let mut bug =
1555
- if backtrace || self . ice_file . is_none ( ) { bug. decorate ( ) } else { bug. inner } ;
1556
1557
1557
- if no_bugs {
1558
+ if i == 0 {
1558
1559
// Put the overall explanation before the `DelayedBug`s, to
1559
1560
// frame them better (e.g. separate warnings from them).
1560
1561
self . emit_diagnostic ( Diagnostic :: new ( Bug , explanation) ) ;
1561
- no_bugs = false ;
1562
1562
}
1563
1563
1564
+ let mut bug =
1565
+ if backtrace || self . ice_file . is_none ( ) { bug. decorate ( ) } else { bug. inner } ;
1566
+
1564
1567
// "Undelay" the `DelayedBug`s (into plain `Bug`s).
1565
1568
if bug. level != Level :: DelayedBug {
1566
1569
// NOTE(eddyb) not panicking here because we're already producing
@@ -1576,9 +1579,7 @@ impl DiagCtxtInner {
1576
1579
}
1577
1580
1578
1581
// Panic with `DelayedBugPanic` to avoid "unexpected panic" messages.
1579
- if !no_bugs {
1580
- panic:: panic_any ( DelayedBugPanic ) ;
1581
- }
1582
+ panic:: panic_any ( DelayedBugPanic ) ;
1582
1583
}
1583
1584
1584
1585
fn bump_lint_err_count ( & mut self ) {
0 commit comments