@@ -383,7 +383,7 @@ pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, Noted};
383383pub use diagnostic_impls:: {
384384 DiagnosticArgFromDisplay , DiagnosticSymbolList , LabelKind , SingleLabelManySpans ,
385385} ;
386- use std:: backtrace:: Backtrace ;
386+ use std:: backtrace:: { Backtrace , BacktraceStatus } ;
387387
388388/// A handler deals with errors and other compiler output.
389389/// Certain errors (fatal, bug, unimpl) may cause immediate exit,
@@ -1331,7 +1331,7 @@ impl HandlerInner {
13311331 // once *any* errors were emitted (and truncate `delayed_span_bugs`
13321332 // when an error is first emitted, also), but maybe there's a case
13331333 // in which that's not sound? otherwise this is really inefficient.
1334- let backtrace = std:: backtrace:: Backtrace :: force_capture ( ) ;
1334+ let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
13351335 self . delayed_span_bugs
13361336 . push ( DelayedDiagnostic :: with_backtrace ( diagnostic. clone ( ) , backtrace) ) ;
13371337
@@ -1620,7 +1620,7 @@ impl HandlerInner {
16201620 if self . flags . report_delayed_bugs {
16211621 self . emit_diagnostic ( & mut diagnostic) ;
16221622 }
1623- let backtrace = std:: backtrace:: Backtrace :: force_capture ( ) ;
1623+ let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
16241624 self . delayed_good_path_bugs . push ( DelayedDiagnostic :: with_backtrace ( diagnostic, backtrace) ) ;
16251625 }
16261626
@@ -1739,7 +1739,17 @@ impl DelayedDiagnostic {
17391739 }
17401740
17411741 fn decorate ( mut self ) -> Diagnostic {
1742- self . inner . note ( format ! ( "delayed at {}\n {}" , self . inner. emitted_at, self . note) ) ;
1742+ match self . note . status ( ) {
1743+ BacktraceStatus :: Captured => {
1744+ self . inner . note ( format ! ( "delayed at {}\n {}" , self . inner. emitted_at, self . note) ) ;
1745+ }
1746+ // Avoid the needless newline when no backtrace has been captured,
1747+ // the display impl should just be a single line.
1748+ _ => {
1749+ self . inner . note ( format ! ( "delayed at {} - {}" , self . inner. emitted_at, self . note) ) ;
1750+ }
1751+ }
1752+
17431753 self . inner
17441754 }
17451755}
0 commit comments