Skip to content

Commit 27c7c23

Browse files
committed
Rename waiting_cache.
The name `waiting_cache` sounds like it is related to the states `NodeState::Waiting`, but it's not; the cache holds nodes of various states. This commit changes it to `active_state`.
1 parent 75fd4f7 commit 27c7c23

File tree

1 file changed

+14
-14
lines changed
  • src/librustc_data_structures/obligation_forest

1 file changed

+14
-14
lines changed

src/librustc_data_structures/obligation_forest/mod.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub struct ObligationForest<O: ForestObligation> {
149149
/// A cache of the nodes in `nodes`, indexed by predicate. Unfortunately,
150150
/// its contents are not guaranteed to match those of `nodes`. See the
151151
/// comments in `process_obligation` for details.
152-
waiting_cache: FxHashMap<O::Predicate, usize>,
152+
active_cache: FxHashMap<O::Predicate, usize>,
153153

154154
/// A scratch vector reused in various operations, to avoid allocating new
155155
/// vectors.
@@ -278,7 +278,7 @@ impl<O: ForestObligation> ObligationForest<O> {
278278
ObligationForest {
279279
nodes: vec![],
280280
done_cache: Default::default(),
281-
waiting_cache: Default::default(),
281+
active_cache: Default::default(),
282282
scratch: RefCell::new(vec![]),
283283
obligation_tree_id_generator: (0..).map(ObligationTreeId),
284284
error_cache: Default::default(),
@@ -303,15 +303,15 @@ impl<O: ForestObligation> ObligationForest<O> {
303303
return Ok(());
304304
}
305305

306-
match self.waiting_cache.entry(obligation.as_predicate().clone()) {
306+
match self.active_cache.entry(obligation.as_predicate().clone()) {
307307
Entry::Occupied(o) => {
308308
debug!("register_obligation_at({:?}, {:?}) - duplicate of {:?}!",
309309
obligation, parent, o.get());
310310
let node = &mut self.nodes[*o.get()];
311311
if let Some(parent_index) = parent {
312-
// If the node is already in `waiting_cache`, it has
313-
// already had its chance to be marked with a parent. So if
314-
// it's not already present, just dump `parent` into the
312+
// If the node is already in `active_cache`, it has already
313+
// had its chance to be marked with a parent. So if it's
314+
// not already present, just dump `parent` into the
315315
// dependents as a non-parent.
316316
if !node.dependents.contains(&parent_index) {
317317
node.dependents.push(parent_index);
@@ -405,8 +405,8 @@ impl<O: ForestObligation> ObligationForest<O> {
405405

406406
// `processor.process_obligation` can modify the predicate within
407407
// `node.obligation`, and that predicate is the key used for
408-
// `self.waiting_cache`. This means that `self.waiting_cache` can
409-
// get out of sync with `nodes`. It's not very common, but it does
408+
// `self.active_cache`. This means that `self.active_cache` can get
409+
// out of sync with `nodes`. It's not very common, but it does
410410
// happen, and code in `compress` has to allow for it.
411411
let result = match node.state.get() {
412412
NodeState::Pending => processor.process_obligation(&mut node.obligation),
@@ -637,11 +637,11 @@ impl<O: ForestObligation> ObligationForest<O> {
637637
}
638638
NodeState::Done => {
639639
// This lookup can fail because the contents of
640-
// `self.waiting_cache` is not guaranteed to match those of
640+
// `self.active_cache` is not guaranteed to match those of
641641
// `self.nodes`. See the comment in `process_obligation`
642642
// for more details.
643-
if let Some((predicate, _)) = self.waiting_cache
644-
.remove_entry(node.obligation.as_predicate())
643+
if let Some((predicate, _)) =
644+
self.active_cache.remove_entry(node.obligation.as_predicate())
645645
{
646646
self.done_cache.insert(predicate);
647647
} else {
@@ -654,7 +654,7 @@ impl<O: ForestObligation> ObligationForest<O> {
654654
// We *intentionally* remove the node from the cache at this point. Otherwise
655655
// tests must come up with a different type on every type error they
656656
// check against.
657-
self.waiting_cache.remove(node.obligation.as_predicate());
657+
self.active_cache.remove(node.obligation.as_predicate());
658658
node_rewrites[index] = nodes_len;
659659
dead_nodes += 1;
660660
self.insert_into_error_cache(index);
@@ -714,9 +714,9 @@ impl<O: ForestObligation> ObligationForest<O> {
714714
}
715715
}
716716

717-
// This updating of `self.waiting_cache` is necessary because the
717+
// This updating of `self.active_cache` is necessary because the
718718
// removal of nodes within `compress` can fail. See above.
719-
self.waiting_cache.retain(|_predicate, index| {
719+
self.active_cache.retain(|_predicate, index| {
720720
let new_index = node_rewrites[*index];
721721
if new_index >= nodes_len {
722722
false

0 commit comments

Comments
 (0)