File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -107,18 +107,21 @@ where
107107
108108 // Build the forest of specialization relationships.
109109 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.
112110 let mut forest = DiGraph :: new ( ) ;
113111
114112 // Find all specializations (implemented in coherence/solve)
115113 // Record them in the forest by adding an edge from the less special
116114 // to the more special.
117115 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 ( ) ;
120117
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+ }
122125 } ) ?;
123126
124127 Ok ( forest)
You can’t perform that action at this time.
0 commit comments