From 0fc0f34ae4fdae562b445e26778c64d60b69cf02 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Thu, 9 Apr 2020 19:24:09 -0700 Subject: Use tri-color search for unconditional recursion lint --- src/librustc_data_structures/graph/iterate/mod.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/librustc_data_structures') diff --git a/src/librustc_data_structures/graph/iterate/mod.rs b/src/librustc_data_structures/graph/iterate/mod.rs index d9d4c7e321f..64ff6130ddf 100644 --- a/src/librustc_data_structures/graph/iterate/mod.rs +++ b/src/librustc_data_structures/graph/iterate/mod.rs @@ -209,7 +209,9 @@ where // schedule its successors for examination. self.stack.push(Event { node, becomes: Settled }); for succ in self.graph.successors(node) { - self.stack.push(Event { node: succ, becomes: Visited }); + if !visitor.ignore_edge(node, succ) { + self.stack.push(Event { node: succ, becomes: Visited }); + } } } } @@ -255,16 +257,21 @@ where /// [CLR]: https://en.wikipedia.org/wiki/Introduction_to_Algorithms fn node_examined( &mut self, - _target: G::Node, + _node: G::Node, _prior_status: Option, ) -> ControlFlow { ControlFlow::Continue } /// Called after all nodes reachable from this one have been examined. - fn node_settled(&mut self, _target: G::Node) -> ControlFlow { + fn node_settled(&mut self, _node: G::Node) -> ControlFlow { ControlFlow::Continue } + + /// Behave as if no edges exist from `source` to `target`. + fn ignore_edge(&mut self, _source: G::Node, _target: G::Node) -> bool { + false + } } /// This `TriColorVisitor` looks for back edges in a graph, which indicate that a cycle exists. -- cgit 1.4.1-3-g733a5