Skip to content

Commit c9d3afd

Browse files
committed
Revert "Attempt to simplify graph logic"
This reverts commit 1b8f032.
1 parent d608852 commit c9d3afd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

chalk-solve/src/coherence.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,19 @@ where
108108
fn build_specialization_forest(&self) -> Result<Graph<ImplId<I>, ()>, CoherenceError<I>> {
109109
let mut forest = DiGraph::new();
110110

111+
let node_impls: Vec<ImplId<_>> = forest.raw_nodes().iter().map(|x| x.weight).collect();
112+
111113
// Find all specializations (implemented in coherence/solve)
112114
// Record them in the forest by adding an edge from the less special
113115
// to the more special.
114116
self.visit_specializations_of_trait(|less_special, more_special| {
115117
// Check so that we never add multiple nodes with the same ImplId.
116-
let l = forest.add_node(less_special);
117-
let m = forest.add_node(more_special);
118+
if !node_impls.contains(&less_special) && !node_impls.contains(&more_special) {
119+
let l = forest.add_node(less_special);
120+
let m = forest.add_node(more_special);
118121

119-
forest.update_edge(l, m, ());
122+
forest.add_edge(l, m, ());
123+
}
120124
})?;
121125

122126
Ok(forest)

0 commit comments

Comments
 (0)