@@ -1321,34 +1321,39 @@ impl DiagCtxtInner {
1321
1321
self . future_breakage_diagnostics . push ( diagnostic. clone ( ) ) ;
1322
1322
}
1323
1323
1324
- // Note that because this comes before the `match` below,
1325
- // `-Zeagerly-emit-delayed-bugs` continues to work even after we've
1326
- // issued an error and stopped recording new delayed bugs.
1327
- if diagnostic. level == DelayedBug && self . flags . eagerly_emit_delayed_bugs {
1328
- diagnostic. level = Error ;
1329
- }
1330
-
1331
1324
match diagnostic. level {
1332
- // This must come after the possible promotion of `DelayedBug` to
1333
- // `Error` above.
1334
1325
Fatal | Error if self . treat_next_err_as_bug ( ) => {
1326
+ // `Fatal` and `Error` can be promoted to `Bug`.
1335
1327
diagnostic. level = Bug ;
1336
1328
}
1337
1329
DelayedBug => {
1338
- // If we have already emitted at least one error, we don't need
1339
- // to record the delayed bug, because it'll never be used.
1340
- return if let Some ( guar) = self . has_errors_or_lint_errors ( ) {
1341
- Some ( guar)
1330
+ // Note that because we check these conditions first,
1331
+ // `-Zeagerly-emit-delayed-bugs` and `-Ztreat-err-as-bug`
1332
+ // continue to work even after we've issued an error and
1333
+ // stopped recording new delayed bugs.
1334
+ if self . flags . eagerly_emit_delayed_bugs {
1335
+ // `DelayedBug` can be promoted to `Error` or `Bug`.
1336
+ if self . treat_next_err_as_bug ( ) {
1337
+ diagnostic. level = Bug ;
1338
+ } else {
1339
+ diagnostic. level = Error ;
1340
+ }
1342
1341
} else {
1343
- let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
1344
- // This `unchecked_error_guaranteed` is valid. It is where the
1345
- // `ErrorGuaranteed` for delayed bugs originates.
1346
- #[ allow( deprecated) ]
1347
- let guar = ErrorGuaranteed :: unchecked_error_guaranteed ( ) ;
1348
- self . delayed_bugs
1349
- . push ( ( DelayedDiagnostic :: with_backtrace ( diagnostic, backtrace) , guar) ) ;
1350
- Some ( guar)
1351
- } ;
1342
+ // If we have already emitted at least one error, we don't need
1343
+ // to record the delayed bug, because it'll never be used.
1344
+ return if let Some ( guar) = self . has_errors_or_lint_errors ( ) {
1345
+ Some ( guar)
1346
+ } else {
1347
+ let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
1348
+ // This `unchecked_error_guaranteed` is valid. It is where the
1349
+ // `ErrorGuaranteed` for delayed bugs originates.
1350
+ #[ allow( deprecated) ]
1351
+ let guar = ErrorGuaranteed :: unchecked_error_guaranteed ( ) ;
1352
+ self . delayed_bugs
1353
+ . push ( ( DelayedDiagnostic :: with_backtrace ( diagnostic, backtrace) , guar) ) ;
1354
+ Some ( guar)
1355
+ } ;
1356
+ }
1352
1357
}
1353
1358
Warning if !self . flags . can_emit_warnings => {
1354
1359
if diagnostic. has_future_breakage ( ) {
0 commit comments