about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-06-07 14:32:11 +0000
committerbors <bors@rust-lang.org>2023-06-07 14:32:11 +0000
commitb2807b2bf3be9fbed9a0aadc97841c20a1ab5f79 (patch)
treef8861cada9423965104c8fb57a7dbfdf1cd68a15 /compiler/rustc_errors/src
parente94bda3bf13303671427363d1cd93ac5e089f090 (diff)
parent90c361c8376e8ec9d63cbd78b6d68c9647eb32c1 (diff)
downloadrust-b2807b2bf3be9fbed9a0aadc97841c20a1ab5f79.tar.gz
rust-b2807b2bf3be9fbed9a0aadc97841c20a1ab5f79.zip
Auto merge of #112383 - Dylan-DPC:rollup-et2z6nt, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #112076 (Fall back to bidirectional normalizes-to if no subst-relate candidate in alias-relate goal)
 - #112122 (Add `-Ztrait-solver=next-coherence`)
 - #112251 (rustdoc: convert `if let Some()` that always matches to variable)
 - #112345 (fix(expand): prevent infinity loop in macro containing only "///")
 - #112359 (Respect `RUST_BACKTRACE` for delayed bugs)
 - #112382 (download-rustc: Fix `x test core` on MacOS)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/lib.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index bf77ed81f9b..7a297ea0d5f 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -383,7 +383,7 @@ pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, Noted};
 pub use diagnostic_impls::{
     DiagnosticArgFromDisplay, DiagnosticSymbolList, LabelKind, SingleLabelManySpans,
 };
-use std::backtrace::Backtrace;
+use std::backtrace::{Backtrace, BacktraceStatus};
 
 /// A handler deals with errors and other compiler output.
 /// Certain errors (fatal, bug, unimpl) may cause immediate exit,
@@ -1331,7 +1331,7 @@ impl HandlerInner {
             // once *any* errors were emitted (and truncate `delayed_span_bugs`
             // when an error is first emitted, also), but maybe there's a case
             // in which that's not sound? otherwise this is really inefficient.
-            let backtrace = std::backtrace::Backtrace::force_capture();
+            let backtrace = std::backtrace::Backtrace::capture();
             self.delayed_span_bugs
                 .push(DelayedDiagnostic::with_backtrace(diagnostic.clone(), backtrace));
 
@@ -1620,7 +1620,7 @@ impl HandlerInner {
         if self.flags.report_delayed_bugs {
             self.emit_diagnostic(&mut diagnostic);
         }
-        let backtrace = std::backtrace::Backtrace::force_capture();
+        let backtrace = std::backtrace::Backtrace::capture();
         self.delayed_good_path_bugs.push(DelayedDiagnostic::with_backtrace(diagnostic, backtrace));
     }
 
@@ -1739,7 +1739,17 @@ impl DelayedDiagnostic {
     }
 
     fn decorate(mut self) -> Diagnostic {
-        self.inner.note(format!("delayed at {}\n{}", self.inner.emitted_at, self.note));
+        match self.note.status() {
+            BacktraceStatus::Captured => {
+                self.inner.note(format!("delayed at {}\n{}", self.inner.emitted_at, self.note));
+            }
+            // Avoid the needless newline when no backtrace has been captured,
+            // the display impl should just be a single line.
+            _ => {
+                self.inner.note(format!("delayed at {} - {}", self.inner.emitted_at, self.note));
+            }
+        }
+
         self.inner
     }
 }