Skip to content

Commit

Permalink
Add back crate graph deduplication
Browse files Browse the repository at this point in the history
  • Loading branch information
LHolten committed Dec 31, 2024
1 parent 431aab1 commit 5b51c4c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ impl CrateGraph {
mut other: CrateGraph,
proc_macros: &mut ProcMacroPaths,
) -> FxHashMap<CrateId, CrateId> {
self.sort_deps();
let topo = other.crates_in_topological_order();
let mut id_map: FxHashMap<CrateId, CrateId> = FxHashMap::default();
for topo in topo {
Expand All @@ -513,7 +514,9 @@ impl CrateGraph {
crate_data.dependencies.iter_mut().for_each(|dep| dep.crate_id = id_map[&dep.crate_id]);
crate_data.dependencies.sort_by_key(|dep| dep.crate_id);

let new_id = self.arena.alloc(crate_data.clone());
let find = self.arena.iter().find(|(_, v)| *v == crate_data);
let new_id =
if let Some((k, _)) = find { k } else { self.arena.alloc(crate_data.clone()) };
id_map.insert(topo, new_id);
}

Expand Down

0 comments on commit 5b51c4c

Please sign in to comment.