Skip to content

Commit 4bd5505

Browse files
committed
Only compute Obligation cache_key once in register_obligation_at
1 parent 0309953 commit 4bd5505

File tree

1 file changed

+4
-3
lines changed
  • compiler/rustc_data_structures/src/obligation_forest

1 file changed

+4
-3
lines changed

compiler/rustc_data_structures/src/obligation_forest/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,13 @@ impl<O: ForestObligation> ObligationForest<O> {
336336

337337
// Returns Err(()) if we already know this obligation failed.
338338
fn register_obligation_at(&mut self, obligation: O, parent: Option<usize>) -> Result<(), ()> {
339-
if self.done_cache.contains(&obligation.as_cache_key()) {
339+
let cache_key = obligation.as_cache_key();
340+
if self.done_cache.contains(&cache_key) {
340341
debug!("register_obligation_at: ignoring already done obligation: {:?}", obligation);
341342
return Ok(());
342343
}
343344

344-
match self.active_cache.entry(obligation.as_cache_key()) {
345+
match self.active_cache.entry(cache_key.clone()) {
345346
Entry::Occupied(o) => {
346347
let node = &mut self.nodes[*o.get()];
347348
if let Some(parent_index) = parent {
@@ -365,7 +366,7 @@ impl<O: ForestObligation> ObligationForest<O> {
365366
&& self
366367
.error_cache
367368
.get(&obligation_tree_id)
368-
.map(|errors| errors.contains(&obligation.as_cache_key()))
369+
.map(|errors| errors.contains(&cache_key))
369370
.unwrap_or(false);
370371

371372
if already_failed {

0 commit comments

Comments
 (0)