Skip to content

Commit 48c85c5

Browse files
committed
Filtering spans
1 parent b15e2c1 commit 48c85c5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/rustc_errors/src/json.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl Diagnostic {
319319
message: translated_message.to_string(),
320320
code: None,
321321
level: "help",
322-
spans: DiagnosticSpan::from_suggestion(sugg, &args, je),
322+
spans: Self::filter_empty_spans_with_no_replacement(DiagnosticSpan::from_suggestion(sugg, &args, je)),
323323
children: vec![],
324324
rendered: None,
325325
}
@@ -372,6 +372,12 @@ impl Diagnostic {
372372
}
373373
}
374374

375+
fn filter_empty_spans_with_no_replacement(spans: Vec<DiagnosticSpan>) -> Vec<DiagnosticSpan> {
376+
spans.into_iter()
377+
.filter(|span| !(span.byte_start == span.byte_end && span.suggested_replacement == Some(String::new())))
378+
.collect()
379+
}
380+
375381
fn from_sub_diagnostic(
376382
diag: &SubDiagnostic,
377383
args: &FluentArgs<'_>,

0 commit comments

Comments
 (0)