Skip to content

Commit

Permalink
Improve pushing to Node::dependents.
Browse files Browse the repository at this point in the history
This patch makes it impossible for a node to end up in both
`node.parent` and `node.dependents`.
  • Loading branch information
nnethercote committed Jun 18, 2018
1 parent 2b973e6 commit 6151bab
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/librustc_data_structures/obligation_forest/mod.rs
Expand Up @@ -193,15 +193,18 @@ impl<O: ForestObligation> ObligationForest<O> {
Entry::Occupied(o) => {
debug!("register_obligation_at({:?}, {:?}) - duplicate of {:?}!",
obligation, parent, o.get());
let node = &mut self.nodes[o.get().get()];
if let Some(parent) = parent {
if self.nodes[o.get().get()].dependents.contains(&parent) {
debug!("register_obligation_at({:?}, {:?}) - duplicate subobligation",
obligation, parent);
} else {
self.nodes[o.get().get()].dependents.push(parent);
// If the node is already in `waiting_cache`, it's already
// been marked with a parent. (It's possible that parent
// has been cleared by `apply_rewrites`, though.) So just
// dump `parent` into `node.dependents`... unless it's
// already in `node.dependents` or `node.parent`.
if !node.dependents.contains(&parent) && Some(parent) != node.parent {
node.dependents.push(parent);
}
}
if let NodeState::Error = self.nodes[o.get().get()].state.get() {
if let NodeState::Error = node.state.get() {
Err(())
} else {
Ok(())
Expand Down

0 comments on commit 6151bab

Please sign in to comment.