Skip to content

Commit 94e0e88

Browse files
Rollup merge of rust-lang#146347 - folkertdev:duplicate-symbol-panic, r=fee1-dead
report duplicate symbols added by the driver The panic message did not mention what symbols were duplicates, which made the panic hard to debug. This came up in [#t-compiler/help > Easiest way to find offending duplicate symbols](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Easiest.20way.20to.20find.20offending.20duplicate.20symbols/with/538295740). This behavior was introduced in rust-lang#138682. r? `@fee1-dead`
2 parents 7dc5bad + eba0934 commit 94e0e88

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

compiler/rustc_span/src/symbol.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::ops::Deref;
77
use std::{fmt, str};
88

99
use rustc_arena::DroplessArena;
10-
use rustc_data_structures::fx::FxIndexSet;
10+
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
1111
use rustc_data_structures::stable_hasher::{
1212
HashStable, StableCompare, StableHasher, ToStableHashKey,
1313
};
@@ -2867,11 +2867,20 @@ impl Interner {
28672867
let byte_strs = FxIndexSet::from_iter(
28682868
init.iter().copied().chain(extra.iter().copied()).map(|str| str.as_bytes()),
28692869
);
2870-
assert_eq!(
2871-
byte_strs.len(),
2872-
init.len() + extra.len(),
2873-
"duplicate symbols in the rustc symbol list and the extra symbols added by the driver",
2874-
);
2870+
2871+
// The order in which duplicates are reported is irrelevant.
2872+
#[expect(rustc::potential_query_instability)]
2873+
if byte_strs.len() != init.len() + extra.len() {
2874+
panic!(
2875+
"duplicate symbols in the rustc symbol list and the extra symbols added by the driver: {:?}",
2876+
FxHashSet::intersection(
2877+
&init.iter().copied().collect(),
2878+
&extra.iter().copied().collect(),
2879+
)
2880+
.collect::<Vec<_>>()
2881+
)
2882+
}
2883+
28752884
Interner(Lock::new(InternerInner { arena: Default::default(), byte_strs }))
28762885
}
28772886

0 commit comments

Comments
 (0)