From 272c324b25ebbb05d5de4f55268ded976d863210 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 28 Sep 2017 13:26:15 +0200 Subject: [PATCH] incr.comp.: Build DepGraphQuery from new dep-graph impl. --- src/librustc/dep_graph/edges.rs | 13 +------------ src/librustc/dep_graph/graph.rs | 13 ++++++++++++- src/librustc_incremental/assert_dep_graph.rs | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/librustc/dep_graph/edges.rs b/src/librustc/dep_graph/edges.rs index b12db11cb6a..241bec39256 100644 --- a/src/librustc/dep_graph/edges.rs +++ b/src/librustc/dep_graph/edges.rs @@ -14,7 +14,7 @@ use rustc_data_structures::stable_hasher::StableHasher; use std::env; use std::hash::Hash; use std::mem; -use super::{DepGraphQuery, DepKind, DepNode}; +use super::{DepKind, DepNode}; use super::debug::EdgeFilter; pub(super) struct DepGraphEdges { @@ -89,10 +89,6 @@ impl DepGraphEdges { } } - fn id(&self, index: DepNodeIndex) -> DepNode { - self.nodes[index.index()] - } - pub fn push_ignore(&mut self) { self.task_stack.push(OpenTask::Ignore); } @@ -231,13 +227,6 @@ impl DepGraphEdges { self.read(dep_node); } - pub fn query(&self) -> DepGraphQuery { - let edges: Vec<_> = self.edges.iter() - .map(|&(i, j)| (self.id(i), self.id(j))) - .collect(); - DepGraphQuery::new(&self.nodes, &edges) - } - #[inline] pub fn add_edge(&mut self, source: DepNode, target: DepNode) { let source = self.get_or_create_node(source); diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index cc15922bc2e..07e3fb45cc6 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -140,7 +140,18 @@ impl DepGraph { } pub fn query(&self) -> DepGraphQuery { - self.data.as_ref().unwrap().edges.borrow().query() + let current_dep_graph = self.data.as_ref().unwrap().current.borrow(); + let nodes: Vec<_> = current_dep_graph.nodes.iter().cloned().collect(); + let mut edges = Vec::new(); + for (index, edge_targets) in current_dep_graph.edges.iter_enumerated() { + let from = current_dep_graph.nodes[index]; + for &edge_target in edge_targets { + let to = current_dep_graph.nodes[edge_target]; + edges.push((from, to)); + } + } + + DepGraphQuery::new(&nodes[..], &edges[..]) } pub fn in_ignore<'graph>(&'graph self) -> Option> { diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 1d58d179960..acbd3e0d63d 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -209,7 +209,7 @@ fn check_paths<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let query = tcx.dep_graph.query(); for &(_, source_def_id, ref source_dep_node) in if_this_changed { - let dependents = query.transitive_successors(source_dep_node); + let dependents = query.transitive_predecessors(source_dep_node); for &(target_span, ref target_pass, _, ref target_dep_node) in then_this_would_need { if !dependents.contains(&target_dep_node) { tcx.sess.span_err(