Skip to content

Commit 5b51c4c

Browse files
committed
Add back crate graph deduplication
1 parent 431aab1 commit 5b51c4c

File tree

1 file changed

+4
-1
lines changed
  • src/tools/rust-analyzer/crates/base-db/src

1 file changed

+4
-1
lines changed

src/tools/rust-analyzer/crates/base-db/src/input.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ impl CrateGraph {
505505
mut other: CrateGraph,
506506
proc_macros: &mut ProcMacroPaths,
507507
) -> FxHashMap<CrateId, CrateId> {
508+
self.sort_deps();
508509
let topo = other.crates_in_topological_order();
509510
let mut id_map: FxHashMap<CrateId, CrateId> = FxHashMap::default();
510511
for topo in topo {
@@ -513,7 +514,9 @@ impl CrateGraph {
513514
crate_data.dependencies.iter_mut().for_each(|dep| dep.crate_id = id_map[&dep.crate_id]);
514515
crate_data.dependencies.sort_by_key(|dep| dep.crate_id);
515516

516-
let new_id = self.arena.alloc(crate_data.clone());
517+
let find = self.arena.iter().find(|(_, v)| *v == crate_data);
518+
let new_id =
519+
if let Some((k, _)) = find { k } else { self.arena.alloc(crate_data.clone()) };
517520
id_map.insert(topo, new_id);
518521
}
519522

0 commit comments

Comments
 (0)