Skip to content

Commit 6bb0693

Browse files
incr.comp.: Assert that no DepNode is re-opened (see issue #42298).
1 parent 6e8452e commit 6bb0693

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ define_dep_nodes!( <'tcx>
394394
// Represents different phases in the compiler.
395395
[] RegionMaps(DefId),
396396
[] Coherence,
397+
[] CoherenceInherentImplOverlapCheck,
397398
[] Resolve,
398399
[] CoherenceCheckTrait(DefId),
399400
[] PrivacyAccessLevels(CrateNum),

src/librustc/dep_graph/edges.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ pub struct DepGraphEdges {
2323
edges: FxHashSet<(DepNodeIndex, DepNodeIndex)>,
2424
task_stack: Vec<OpenTask>,
2525
forbidden_edge: Option<EdgeFilter>,
26+
27+
// A set to help assert that no two tasks use the same DepNode. This is a
28+
// temporary measure. Once we load the previous dep-graph as readonly, this
29+
// check will fall out of the graph implementation naturally.
30+
opened_once: FxHashSet<DepNode>,
2631
}
2732

2833
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
@@ -80,6 +85,7 @@ impl DepGraphEdges {
8085
edges: FxHashSet(),
8186
task_stack: Vec::new(),
8287
forbidden_edge,
88+
opened_once: FxHashSet(),
8389
}
8490
}
8591

@@ -97,6 +103,10 @@ impl DepGraphEdges {
97103
}
98104

99105
pub fn push_task(&mut self, key: DepNode) {
106+
if !self.opened_once.insert(key) {
107+
bug!("Re-opened node {:?}", key)
108+
}
109+
100110
self.task_stack.push(OpenTask::Regular {
101111
node: key,
102112
reads: Vec::new(),

src/librustc/ty/maps.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ define_maps! { <'tcx>
931931
/// Checks all types in the krate for overlap in their inherent impls. Reports errors.
932932
/// Not meant to be used directly outside of coherence.
933933
/// (Defined only for LOCAL_CRATE)
934-
[] crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (),
934+
[] crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (),
935935

936936
/// Results of evaluating const items or constants embedded in
937937
/// other items (such as enum variant explicit discriminants).
@@ -1014,6 +1014,10 @@ fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
10141014
DepConstructor::Coherence
10151015
}
10161016

1017+
fn inherent_impls_overlap_check_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
1018+
DepConstructor::CoherenceInherentImplOverlapCheck
1019+
}
1020+
10171021
fn reachability_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
10181022
DepConstructor::Reachability
10191023
}

0 commit comments

Comments
 (0)