Skip to content

Commit 39d8195

Browse files
authored
Rollup merge of #94327 - Mark-Simulacrum:avoid-macro-sp, r=petrochenkov
Avoid emitting full macro body into JSON errors While investigating #94322, it was noted that currently the JSON diagnostics for macro backtraces include the full def_site span -- the whole macro body. It seems like this shouldn't be necessary, so this PR adjusts the span to just be the "guessed head", typically the macro name. It doesn't look like we keep enough information to synthesize a nicer span here at this time. Atop #92123, this reduces output for the src/test/ui/suggestions/missing-lifetime-specifier.rs test from 660 KB to 156 KB locally.
2 parents 25cc094 + 34319ff commit 39d8195

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/rustc_errors/src/json.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,14 @@ impl DiagnosticSpan {
454454
let end = je.sm.lookup_char_pos(span.hi());
455455
let backtrace_step = backtrace.next().map(|bt| {
456456
let call_site = Self::from_span_full(bt.call_site, false, None, None, backtrace, je);
457-
let def_site_span =
458-
Self::from_span_full(bt.def_site, false, None, None, [].into_iter(), je);
457+
let def_site_span = Self::from_span_full(
458+
je.sm.guess_head_span(bt.def_site),
459+
false,
460+
None,
461+
None,
462+
[].into_iter(),
463+
je,
464+
);
459465
Box::new(DiagnosticSpanMacroExpansion {
460466
span: call_site,
461467
macro_decl_name: bt.kind.descr(),

0 commit comments

Comments
 (0)