Skip to content

Commit a245a48

Browse files
Rollup merge of rust-lang#111708 - jyn514:delay-span-bug-msg, r=compiler-errors
Give a more useful location for where a span_bug was delayed Before: ``` = note: delayed at 0: <rustc_errors::HandlerInner>::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:1335:29 1: <rustc_errors::Handler>::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:1124:9 ... ``` After: ``` = note: delayed at compiler/rustc_parse/src/parser/diagnostics.rs:2158:28 0: <rustc_errors::HandlerInner>::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:1335:29 1: <rustc_errors::Handler>::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:1124:9 ... ``` This both makes the relevant frame easier to find without having to dig through diagnostic internals, and avoids the weird-looking formatting for the first frame. Found while working on rust-lang#111529.
2 parents cb36cae + e6a7fde commit a245a48

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

compiler/rustc_errors/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ impl DelayedDiagnostic {
17401740
}
17411741

17421742
fn decorate(mut self) -> Diagnostic {
1743-
self.inner.note(format!("delayed at {}", self.note));
1743+
self.inner.note(format!("delayed at {}\n{}", self.inner.emitted_at, self.note));
17441744
self.inner
17451745
}
17461746
}

compiler/rustc_parse/src/parser/diagnostics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ impl<'a> DerefMut for SnapshotParser<'a> {
238238

239239
impl<'a> Parser<'a> {
240240
#[rustc_lint_diagnostics]
241+
#[track_caller]
241242
pub fn struct_span_err<S: Into<MultiSpan>>(
242243
&self,
243244
sp: S,

0 commit comments

Comments
 (0)