@@ -107,28 +107,19 @@ 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
- // FIXME(pierwill): Previously, the forest was built as a GraphMap
111
- // so that we never add multiple nodes with the same ItemId.
112
- // Will need to add a check for this.
113
110
let mut forest = DiGraph :: new ( ) ;
114
111
115
112
// Find all specializations (implemented in coherence/solve)
116
113
// Record them in the forest by adding an edge from the less special
117
114
// to the more special.
118
115
self . visit_specializations_of_trait ( |less_special, more_special| {
119
- let nodes = forest. raw_nodes ( ) ;
120
- let mut goodnodes: Vec < ImplId < _ > > = vec ! [ ] ;
116
+ let node_impls: Vec < ImplId < _ > > = forest. raw_nodes ( ) . iter ( ) . map ( |x| x. weight ) . collect ( ) ;
121
117
122
- for node in nodes {
123
- goodnodes. push ( node. weight ) ;
124
- }
125
-
126
- if !goodnodes. contains ( & less_special) && !goodnodes. contains ( & more_special) {
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) {
127
120
let l = forest. add_node ( less_special) ;
128
121
let m = forest. add_node ( more_special) ;
129
122
130
- #[ rustfmt:: skip]
131
- println ! ( "adding an edge from {:?} to {:?}" , less_special, more_special ) ;
132
123
forest. add_edge ( l, m, ( ) ) ;
133
124
}
134
125
} ) ?;
0 commit comments