File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -107,18 +107,21 @@ where
107
107
108
108
// Build the forest of specialization relationships.
109
109
fn build_specialization_forest ( & self ) -> Result < Graph < ImplId < I > , ( ) > , CoherenceError < I > > {
110
- // The forest is returned as a graph but built as a GraphMap; this is
111
- // so that we never add multiple nodes with the same ItemId.
112
110
let mut forest = DiGraph :: new ( ) ;
113
111
114
112
// Find all specializations (implemented in coherence/solve)
115
113
// Record them in the forest by adding an edge from the less special
116
114
// to the more special.
117
115
self . visit_specializations_of_trait ( |less_special, more_special| {
118
- let l = forest. add_node ( less_special) ;
119
- let m = forest. add_node ( more_special) ;
116
+ let node_impls: Vec < ImplId < _ > > = forest. raw_nodes ( ) . iter ( ) . map ( |x| x. weight ) . collect ( ) ;
120
117
121
- forest. add_edge ( l, m, ( ) ) ;
118
+ // Check so that we never add multiple nodes with the same ImplId.
119
+ if !node_impls. contains ( & less_special) && !node_impls. contains ( & more_special) {
120
+ let l = forest. add_node ( less_special) ;
121
+ let m = forest. add_node ( more_special) ;
122
+
123
+ forest. add_edge ( l, m, ( ) ) ;
124
+ }
122
125
} ) ?;
123
126
124
127
Ok ( forest)
You can’t perform that action at this time.
0 commit comments