@@ -1377,35 +1377,40 @@ impl DiagCtxtInner {
1377
1377
self . future_breakage_diagnostics . push ( diagnostic. clone ( ) ) ;
1378
1378
}
1379
1379
1380
- // Note that because this comes before the `match` below,
1381
- // `-Zeagerly-emit-delayed-bugs` continues to work even after we've
1382
- // issued an error and stopped recording new delayed bugs.
1383
- if diagnostic. level == DelayedBug && self . flags . eagerly_emit_delayed_bugs {
1384
- diagnostic. level = Error ;
1385
- }
1386
-
1387
1380
match diagnostic. level {
1388
- // This must come after the possible promotion of `DelayedBug` to
1389
- // `Error` above.
1390
1381
Fatal | Error if self . treat_next_err_as_bug ( ) => {
1382
+ // `Fatal` and `Error` can be promoted to `Bug`.
1391
1383
diagnostic. level = Bug ;
1392
1384
}
1393
1385
DelayedBug => {
1394
- // If we have already emitted at least one error, we don't need
1395
- // to record the delayed bug, because it'll never be used.
1396
- return if let Some ( guar) = self . has_errors ( ) {
1397
- Some ( guar)
1386
+ // Note that because we check these conditions first,
1387
+ // `-Zeagerly-emit-delayed-bugs` and `-Ztreat-err-as-bug`
1388
+ // continue to work even after we've issued an error and
1389
+ // stopped recording new delayed bugs.
1390
+ if self . flags . eagerly_emit_delayed_bugs {
1391
+ // `DelayedBug` can be promoted to `Error` or `Bug`.
1392
+ if self . treat_next_err_as_bug ( ) {
1393
+ diagnostic. level = Bug ;
1394
+ } else {
1395
+ diagnostic. level = Error ;
1396
+ }
1398
1397
} else {
1399
- let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
1400
- // This `unchecked_error_guaranteed` is valid. It is where the
1401
- // `ErrorGuaranteed` for delayed bugs originates. See
1402
- // `DiagCtxtInner::drop`.
1403
- #[ allow( deprecated) ]
1404
- let guar = ErrorGuaranteed :: unchecked_error_guaranteed ( ) ;
1405
- self . delayed_bugs
1406
- . push ( ( DelayedDiagInner :: with_backtrace ( diagnostic, backtrace) , guar) ) ;
1407
- Some ( guar)
1408
- } ;
1398
+ // If we have already emitted at least one error, we don't need
1399
+ // to record the delayed bug, because it'll never be used.
1400
+ return if let Some ( guar) = self . has_errors ( ) {
1401
+ Some ( guar)
1402
+ } else {
1403
+ let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
1404
+ // This `unchecked_error_guaranteed` is valid. It is where the
1405
+ // `ErrorGuaranteed` for delayed bugs originates. See
1406
+ // `DiagCtxtInner::drop`.
1407
+ #[ allow( deprecated) ]
1408
+ let guar = ErrorGuaranteed :: unchecked_error_guaranteed ( ) ;
1409
+ self . delayed_bugs
1410
+ . push ( ( DelayedDiagInner :: with_backtrace ( diagnostic, backtrace) , guar) ) ;
1411
+ Some ( guar)
1412
+ } ;
1413
+ }
1409
1414
}
1410
1415
Warning if !self . flags . can_emit_warnings => {
1411
1416
if diagnostic. has_future_breakage ( ) {
0 commit comments