@@ -7,7 +7,7 @@ use cache::ProvisionalCache;
7
7
use overflow:: OverflowData ;
8
8
use rustc_index:: vec:: IndexVec ;
9
9
use rustc_middle:: ty:: TyCtxt ;
10
- use std:: collections:: hash_map:: Entry ;
10
+ use std:: { collections:: hash_map:: Entry , mem } ;
11
11
12
12
rustc_index:: newtype_index! {
13
13
pub struct StackDepth { }
@@ -134,12 +134,15 @@ impl<'tcx> SearchGraph<'tcx> {
134
134
let provisional_entry_index = * cache. lookup_table . get ( & goal) . unwrap ( ) ;
135
135
let provisional_entry = & mut cache. entries [ provisional_entry_index] ;
136
136
let depth = provisional_entry. depth ;
137
+ // We eagerly update the response in the cache here. If we have to reevaluate
138
+ // this goal we use the new response when hitting a cycle, and we definitely
139
+ // want to access the final response whenever we look at the cache.
140
+ let prev_response = mem:: replace ( & mut provisional_entry. response , response) ;
141
+
137
142
// Was the current goal the root of a cycle and was the provisional response
138
143
// different from the final one.
139
- if has_been_used && provisional_entry. response != response {
140
- // If so, update the provisional reponse for this goal...
141
- provisional_entry. response = response;
142
- // ...remove all entries whose result depends on this goal
144
+ if has_been_used && prev_response != response {
145
+ // If so, remove all entries whose result depends on this goal
143
146
// from the provisional cache...
144
147
//
145
148
// That's not completely correct, as a nested goal can also
0 commit comments