From dcf6f08138e7831d75b39e4c11c0a5acc2cd3831 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 18 Aug 2015 17:41:46 -0400 Subject: [PATCH] kill the old funky `can_reach` fn --- src/librustc/util/common.rs | 43 ------------------------------------- 1 file changed, 43 deletions(-) diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 2314368177cb..1ad5ae9917d9 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -203,49 +203,6 @@ pub fn block_query

(b: &ast::Block, p: P) -> bool where P: FnMut(&ast::Expr) - return v.flag; } -/// K: Eq + Hash, V, S, H: Hasher -/// -/// Determines whether there exists a path from `source` to `destination`. The -/// graph is defined by the `edges_map`, which maps from a node `S` to a list of -/// its adjacent nodes `T`. -/// -/// Efficiency note: This is implemented in an inefficient way because it is -/// typically invoked on very small graphs. If the graphs become larger, a more -/// efficient graph representation and algorithm would probably be advised. -pub fn can_reach(edges_map: &HashMap, S>, source: T, - destination: T) -> bool - where S: HashState, T: Hash + Eq + Clone, -{ - if source == destination { - return true; - } - - // Do a little breadth-first-search here. The `queue` list - // doubles as a way to detect if we've seen a particular FR - // before. Note that we expect this graph to be an *extremely - // shallow* tree. - let mut queue = vec!(source); - let mut i = 0; - while i < queue.len() { - match edges_map.get(&queue[i]) { - Some(edges) => { - for target in edges { - if *target == destination { - return true; - } - - if !queue.iter().any(|x| x == target) { - queue.push((*target).clone()); - } - } - } - None => {} - } - i += 1; - } - return false; -} - /// Memoizes a one-argument closure using the given RefCell containing /// a type implementing MutableMap to serve as a cache. ///