@@ -527,6 +527,9 @@ pub struct DiagCtxtFlags {
527527 /// If Some, the Nth error-level diagnostic is upgraded to bug-level.
528528 /// (rustc: see `-Z treat-err-as-bug`)
529529 pub treat_err_as_bug : Option < NonZeroUsize > ,
530+ /// Eagerly emit delayed bugs as errors, so that the compiler debugger may
531+ /// see all of the errors being emitted at once.
532+ pub eagerly_emit_delayed_bugs : bool ,
530533 /// Show macro backtraces.
531534 /// (rustc: see `-Z macro-backtrace`)
532535 pub macro_backtrace : bool ,
@@ -1269,16 +1272,21 @@ impl DiagCtxtInner {
12691272 }
12701273
12711274 if diagnostic. level == DelayedBug {
1272- // FIXME(eddyb) this should check for `has_errors` and stop pushing
1273- // once *any* errors were emitted (and truncate `span_delayed_bugs`
1274- // when an error is first emitted, also), but maybe there's a case
1275- // in which that's not sound? otherwise this is really inefficient.
1276- let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
1277- self . span_delayed_bugs
1278- . push ( DelayedDiagnostic :: with_backtrace ( diagnostic. clone ( ) , backtrace) ) ;
1275+ if self . flags . eagerly_emit_delayed_bugs {
1276+ // Emit error as bug, rather than stashing it.
1277+ diagnostic. level = Error ;
1278+ } else {
1279+ // FIXME(eddyb) this should check for `has_errors` and stop pushing
1280+ // once *any* errors were emitted (and truncate `span_delayed_bugs`
1281+ // when an error is first emitted, also), but maybe there's a case
1282+ // in which that's not sound? otherwise this is really inefficient.
1283+ let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
1284+ self . span_delayed_bugs
1285+ . push ( DelayedDiagnostic :: with_backtrace ( diagnostic. clone ( ) , backtrace) ) ;
12791286
1280- #[ allow( deprecated) ]
1281- return Some ( ErrorGuaranteed :: unchecked_claim_error_was_emitted ( ) ) ;
1287+ #[ allow( deprecated) ]
1288+ return Some ( ErrorGuaranteed :: unchecked_claim_error_was_emitted ( ) ) ;
1289+ }
12821290 }
12831291
12841292 if diagnostic. has_future_breakage ( ) {
0 commit comments