diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-06-07 15:35:10 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-06-18 10:04:23 +1000 |
| commit | 6151bab8e1b94510eeb3929eb969ef8679a24294 (patch) | |
| tree | dee0fcf39f1a58636a075ec7359010f9e8a720c3 /src/librustc_data_structures | |
| parent | 2b973e653257f965e33a61b58c0eb7e863aed6c8 (diff) | |
| download | rust-6151bab8e1b94510eeb3929eb969ef8679a24294.tar.gz rust-6151bab8e1b94510eeb3929eb969ef8679a24294.zip | |
Improve pushing to `Node::dependents`.
This patch makes it impossible for a node to end up in both `node.parent` and `node.dependents`.
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/obligation_forest/mod.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs index 990dc66c66a..c66011d4118 100644 --- a/src/librustc_data_structures/obligation_forest/mod.rs +++ b/src/librustc_data_structures/obligation_forest/mod.rs @@ -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(()) |
