From 6bb0693fdebb68020911f3b9245cebc6f134154e Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 1 Aug 2017 16:34:20 +0200 Subject: [PATCH] incr.comp.: Assert that no DepNode is re-opened (see issue #42298). --- src/librustc/dep_graph/dep_node.rs | 1 + src/librustc/dep_graph/edges.rs | 10 ++++++++++ src/librustc/ty/maps.rs | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 8e2c44a427b7..800689f4638d 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -394,6 +394,7 @@ define_dep_nodes!( <'tcx> // Represents different phases in the compiler. [] RegionMaps(DefId), [] Coherence, + [] CoherenceInherentImplOverlapCheck, [] Resolve, [] CoherenceCheckTrait(DefId), [] PrivacyAccessLevels(CrateNum), diff --git a/src/librustc/dep_graph/edges.rs b/src/librustc/dep_graph/edges.rs index 277b69262c92..9aa634770df9 100644 --- a/src/librustc/dep_graph/edges.rs +++ b/src/librustc/dep_graph/edges.rs @@ -23,6 +23,11 @@ pub struct DepGraphEdges { edges: FxHashSet<(DepNodeIndex, DepNodeIndex)>, task_stack: Vec, forbidden_edge: Option, + + // A set to help assert that no two tasks use the same DepNode. This is a + // temporary measure. Once we load the previous dep-graph as readonly, this + // check will fall out of the graph implementation naturally. + opened_once: FxHashSet, } #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] @@ -80,6 +85,7 @@ impl DepGraphEdges { edges: FxHashSet(), task_stack: Vec::new(), forbidden_edge, + opened_once: FxHashSet(), } } @@ -97,6 +103,10 @@ impl DepGraphEdges { } pub fn push_task(&mut self, key: DepNode) { + if !self.opened_once.insert(key) { + bug!("Re-opened node {:?}", key) + } + self.task_stack.push(OpenTask::Regular { node: key, reads: Vec::new(), diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 7a45a706ea40..d62d8f986c23 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -931,7 +931,7 @@ define_maps! { <'tcx> /// Checks all types in the krate for overlap in their inherent impls. Reports errors. /// Not meant to be used directly outside of coherence. /// (Defined only for LOCAL_CRATE) - [] crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (), + [] crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (), /// Results of evaluating const items or constants embedded in /// other items (such as enum variant explicit discriminants). @@ -1014,6 +1014,10 @@ fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { DepConstructor::Coherence } +fn inherent_impls_overlap_check_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { + DepConstructor::CoherenceInherentImplOverlapCheck +} + fn reachability_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { DepConstructor::Reachability }