Skip to content

Commit

Permalink
Rollup merge of rust-lang#84923 - estebank:as_cache_key-once, r=petro…
Browse files Browse the repository at this point in the history
…chenkov

Only compute Obligation `cache_key` once  in `register_obligation_at`
  • Loading branch information
GuillaumeGomez authored May 5, 2021
2 parents 41d5524 + 4bd5505 commit c6d509a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler/rustc_data_structures/src/obligation_forest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,13 @@ impl<O: ForestObligation> ObligationForest<O> {

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

match self.active_cache.entry(obligation.as_cache_key()) {
match self.active_cache.entry(cache_key.clone()) {
Entry::Occupied(o) => {
let node = &mut self.nodes[*o.get()];
if let Some(parent_index) = parent {
Expand All @@ -365,7 +366,7 @@ impl<O: ForestObligation> ObligationForest<O> {
&& self
.error_cache
.get(&obligation_tree_id)
.map(|errors| errors.contains(&obligation.as_cache_key()))
.map(|errors| errors.contains(&cache_key))
.unwrap_or(false);

if already_failed {
Expand Down

0 comments on commit c6d509a

Please sign in to comment.