1
Fork 0

Fix duplicate labels emitted in render_multispan_macro_backtrace()

Using hash set instead of vec to weed out duplicates
This commit is contained in:
Gurinder Singh 2023-10-19 08:03:40 +05:30
parent 9ace9da2e0
commit 0091166b57
5 changed files with 13 additions and 46 deletions

View file

@ -23,7 +23,7 @@ use crate::{
use rustc_lint_defs::pluralize;
use derive_setters::Setters;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
use rustc_data_structures::sync::{DynSend, IntoDynSyncSend, Lrc};
use rustc_error_messages::{FluentArgs, SpanLabel};
use rustc_span::hygiene::{ExpnKind, MacroKind};
@ -370,7 +370,7 @@ pub trait Emitter: Translate {
}
fn render_multispan_macro_backtrace(&self, span: &mut MultiSpan, always_backtrace: bool) {
let mut new_labels: Vec<(Span, String)> = vec![];
let mut new_labels = FxIndexSet::default();
for &sp in span.primary_spans() {
if sp.is_dummy() {
@ -387,7 +387,7 @@ pub trait Emitter: Translate {
}
if always_backtrace {
new_labels.push((
new_labels.insert((
trace.def_site,
format!(
"in this expansion of `{}`{}",
@ -431,7 +431,7 @@ pub trait Emitter: Translate {
format!("this {} desugaring", kind.descr()).into()
}
};
new_labels.push((
new_labels.insert((
trace.call_site,
format!(
"in {}{}",