Rollup merge of #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 https://github.com/rust-lang/rust/pull/138682. r? ```@fee1-dead```
This commit is contained in:
commit
f38c788d84
1 changed files with 15 additions and 6 deletions
|
|
@ -7,7 +7,7 @@ use std::ops::Deref;
|
|||
use std::{fmt, str};
|
||||
|
||||
use rustc_arena::DroplessArena;
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
||||
use rustc_data_structures::stable_hasher::{
|
||||
HashStable, StableCompare, StableHasher, ToStableHashKey,
|
||||
};
|
||||
|
|
@ -2871,11 +2871,20 @@ impl Interner {
|
|||
let byte_strs = FxIndexSet::from_iter(
|
||||
init.iter().copied().chain(extra.iter().copied()).map(|str| str.as_bytes()),
|
||||
);
|
||||
assert_eq!(
|
||||
byte_strs.len(),
|
||||
init.len() + extra.len(),
|
||||
"duplicate symbols in the rustc symbol list and the extra symbols added by the driver",
|
||||
);
|
||||
|
||||
// The order in which duplicates are reported is irrelevant.
|
||||
#[expect(rustc::potential_query_instability)]
|
||||
if byte_strs.len() != init.len() + extra.len() {
|
||||
panic!(
|
||||
"duplicate symbols in the rustc symbol list and the extra symbols added by the driver: {:?}",
|
||||
FxHashSet::intersection(
|
||||
&init.iter().copied().collect(),
|
||||
&extra.iter().copied().collect(),
|
||||
)
|
||||
.collect::<Vec<_>>()
|
||||
)
|
||||
}
|
||||
|
||||
Interner(Lock::new(InternerInner { arena: Default::default(), byte_strs }))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue