From c0add813e9005a3356c7a8062c9a9c8f8bca6895 Mon Sep 17 00:00:00 2001 From: gfreezy Date: Sat, 22 Dec 2018 22:40:41 +0800 Subject: mark as visited on entry instead of left --- crates/ra_db/src/input.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_db/src') diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index e9a991a57..f445e03bc 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs @@ -118,9 +118,10 @@ impl CrateGraph { self.arena[&crate_id].dependencies.iter() } fn dfs_find(&self, target: CrateId, from: CrateId, visited: &mut FxHashSet) -> bool { - if visited.contains(&from) { + if !visited.insert(from) { return false; } + for dep in self.dependencies(from) { let crate_id = dep.crate_id(); if crate_id == target { @@ -131,7 +132,6 @@ impl CrateGraph { return true; } } - visited.insert(from); return false; } } -- cgit v1.2.3