Skip to content

Commit 6151bab

Browse files
committed
Improve pushing to Node::dependents.
This patch makes it impossible for a node to end up in both `node.parent` and `node.dependents`.
1 parent 2b973e6 commit 6151bab

File tree

1 file changed

+9
-6
lines changed
  • src/librustc_data_structures/obligation_forest

1 file changed

+9
-6
lines changed

src/librustc_data_structures/obligation_forest/mod.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,18 @@ impl<O: ForestObligation> ObligationForest<O> {
193193
Entry::Occupied(o) => {
194194
debug!("register_obligation_at({:?}, {:?}) - duplicate of {:?}!",
195195
obligation, parent, o.get());
196+
let node = &mut self.nodes[o.get().get()];
196197
if let Some(parent) = parent {
197-
if self.nodes[o.get().get()].dependents.contains(&parent) {
198-
debug!("register_obligation_at({:?}, {:?}) - duplicate subobligation",
199-
obligation, parent);
200-
} else {
201-
self.nodes[o.get().get()].dependents.push(parent);
198+
// If the node is already in `waiting_cache`, it's already
199+
// been marked with a parent. (It's possible that parent
200+
// has been cleared by `apply_rewrites`, though.) So just
201+
// dump `parent` into `node.dependents`... unless it's
202+
// already in `node.dependents` or `node.parent`.
203+
if !node.dependents.contains(&parent) && Some(parent) != node.parent {
204+
node.dependents.push(parent);
202205
}
203206
}
204-
if let NodeState::Error = self.nodes[o.get().get()].state.get() {
207+
if let NodeState::Error = node.state.get() {
205208
Err(())
206209
} else {
207210
Ok(())

0 commit comments

Comments
 (0)