]> git.lizzy.rs Git - rust.git/commitdiff
Streamline `active_cache` to `done_cache` transfer.
authorNicholas Nethercote <n.nethercote@gmail.com>
Fri, 3 Jun 2022 01:50:31 +0000 (11:50 +1000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Sun, 5 Jun 2022 22:47:49 +0000 (08:47 +1000)
compiler/rustc_data_structures/src/obligation_forest/mod.rs

index 74f432a7967f9f585feec2709033b71aafd2aae0..c085e18fd66f0bf02ffa52bbdd7c1e35bf3130e9 100644 (file)
@@ -634,17 +634,14 @@ fn compress(&mut self, mut outcome_cb: impl FnMut(&O)) {
                     }
                 }
                 NodeState::Done => {
-                    // This lookup can fail because the contents of
+                    // The removal lookup might fail because the contents of
                     // `self.active_cache` are not guaranteed to match those of
                     // `self.nodes`. See the comment in `process_obligation`
                     // for more details.
-                    if let Some((predicate, _)) =
-                        self.active_cache.remove_entry(&node.obligation.as_cache_key())
-                    {
-                        self.done_cache.insert(predicate);
-                    } else {
-                        self.done_cache.insert(node.obligation.as_cache_key().clone());
-                    }
+                    let cache_key = node.obligation.as_cache_key();
+                    self.active_cache.remove(&cache_key);
+                    self.done_cache.insert(cache_key);
+
                     // Extract the success stories.
                     outcome_cb(&node.obligation);
                     node_rewrites[index] = orig_nodes_len;