@@ -109,7 +109,6 @@ where
109
109
fn build_specialization_forest ( & self ) -> Result < Graph < ImplId < I > , ( ) > , CoherenceError < I > > {
110
110
// FIXME(pierwill): Previously, the forest was built as a GraphMap
111
111
// so that we never add multiple nodes with the same ItemId.
112
- // Will need to add a check for this.
113
112
let mut forest = DiGraph :: new ( ) ;
114
113
115
114
// Find all specializations (implemented in coherence/solve)
@@ -119,7 +118,24 @@ where
119
118
let l = forest. add_node ( less_special) ;
120
119
let m = forest. add_node ( more_special) ;
121
120
122
- forest. add_edge ( l, m, ( ) ) ;
121
+ // attempt to handle FIXME above...
122
+ let ( nodes, _) = forest. clone ( ) . into_nodes_edges ( ) ;
123
+ let mut already_exists = false ;
124
+ for x in nodes {
125
+ // this isn't doing what we want...
126
+ // `ItemId`? 🤔
127
+ if !( less_special != x. weight && more_special != x. weight ) {
128
+ already_exists = true ;
129
+ }
130
+ }
131
+ println ! ( "Already exists? {}" , already_exists) ;
132
+ if !already_exists {
133
+ println ! (
134
+ "adding an edge from {:?} to {:?}" ,
135
+ less_special, more_special
136
+ ) ;
137
+ forest. add_edge ( l, m, ( ) ) ;
138
+ }
123
139
} ) ?;
124
140
125
141
Ok ( forest)
0 commit comments