@@ -1300,7 +1300,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13001300
13011301 let cycles = self . tree . rerun_get_and_reset_cycles ( prev_stack_entry. node_id ) ;
13021302 let current_stack_len = self . stack . len ( ) ;
1303- let mut has_changed = HashSet :: default ( ) ;
1303+ let mut was_reevaluated = HashSet :: default ( ) ;
13041304 ' outer: for cycle in cycles {
13051305 let & tree:: Cycle { node_id : cycle_node_id, ref provisional_results } =
13061306 self . tree . get_cycle ( cycle) ;
@@ -1329,7 +1329,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13291329 // We've evaluated the `entry_node_id` before evaluating this goal. In case
13301330 // that node and its parents has not changed, we can reinsert the cache entry
13311331 // before starting to reevaluate it.
1332- if !self . tree . goal_or_parent_has_changed ( node_id, & has_changed , entry_node_id) {
1332+ if !self . tree . goal_or_parent_was_reevaluated ( node_id, & was_reevaluated , entry_node_id) {
13331333 continue ;
13341334 }
13351335 }
@@ -1369,7 +1369,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13691369 }
13701370 }
13711371 ( Some ( & ( node_id, info) ) , None ) => {
1372- if current_goal . 0 == node_id {
1372+ if was_reevaluated . contains ( & node_id) {
13731373 debug ! ( parent = ?info. input, cycle = ?added_goals. last( ) . unwrap( ) , "reevaluated parent, skip cycle" ) ;
13741374 continue ' outer;
13751375 } else {
@@ -1427,15 +1427,12 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
14271427 current_goal. 1 . step_kind_from_parent ,
14281428 inspect,
14291429 ) ;
1430+ was_reevaluated. insert ( current_goal. 0 ) ;
14301431 if node_id. is_some_and ( |node_id| self . tree . result_matches ( current_goal. 0 , node_id) )
14311432 {
1432- // TODO: This seems wrong. If a later loop reevaluates this goal again, we'd use
1433- // its updated `NodeId`.
1434- removed_entries. remove ( & current_goal. 0 ) ;
14351433 debug ! ( input = ?current_goal. 1 . input, ?result, "goal did not change" ) ;
14361434 continue ' outer;
14371435 } else {
1438- has_changed. insert ( current_goal. 0 ) ;
14391436 debug ! ( input = ?current_goal. 1 . input, ?result, "goal did change" ) ;
14401437 if self . stack . len ( ) > current_stack_len {
14411438 let parent = self . stack . pop ( ) ;
@@ -1481,7 +1478,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
14811478 ) ;
14821479
14831480 for ( entry_node_id, ( input, entry) ) in removed_entries {
1484- if !self . tree . goal_or_parent_has_changed ( node_id, & has_changed , entry_node_id) {
1481+ if !self . tree . goal_or_parent_was_reevaluated ( node_id, & was_reevaluated , entry_node_id) {
14851482 self . provisional_cache . entry ( input) . or_default ( ) . push ( entry) ;
14861483 }
14871484 }
0 commit comments