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