@@ -383,7 +383,7 @@ pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, Noted};
383
383
pub use diagnostic_impls:: {
384
384
DiagnosticArgFromDisplay , DiagnosticSymbolList , LabelKind , SingleLabelManySpans ,
385
385
} ;
386
- use std:: backtrace:: Backtrace ;
386
+ use std:: backtrace:: { Backtrace , BacktraceStatus } ;
387
387
388
388
/// A handler deals with errors and other compiler output.
389
389
/// Certain errors (fatal, bug, unimpl) may cause immediate exit,
@@ -1331,7 +1331,7 @@ impl HandlerInner {
1331
1331
// once *any* errors were emitted (and truncate `delayed_span_bugs`
1332
1332
// when an error is first emitted, also), but maybe there's a case
1333
1333
// 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 ( ) ;
1335
1335
self . delayed_span_bugs
1336
1336
. push ( DelayedDiagnostic :: with_backtrace ( diagnostic. clone ( ) , backtrace) ) ;
1337
1337
@@ -1620,7 +1620,7 @@ impl HandlerInner {
1620
1620
if self . flags . report_delayed_bugs {
1621
1621
self . emit_diagnostic ( & mut diagnostic) ;
1622
1622
}
1623
- let backtrace = std:: backtrace:: Backtrace :: force_capture ( ) ;
1623
+ let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
1624
1624
self . delayed_good_path_bugs . push ( DelayedDiagnostic :: with_backtrace ( diagnostic, backtrace) ) ;
1625
1625
}
1626
1626
@@ -1739,7 +1739,17 @@ impl DelayedDiagnostic {
1739
1739
}
1740
1740
1741
1741
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
+
1743
1753
self . inner
1744
1754
}
1745
1755
}
0 commit comments