mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-11 20:58:54 +00:00
rename to dfs_find
This commit is contained in:
parent
792dabc0a6
commit
77eaa208ed
1 changed files with 3 additions and 3 deletions
|
@ -94,7 +94,7 @@ impl CrateGraph {
|
||||||
crate_id
|
crate_id
|
||||||
}
|
}
|
||||||
pub fn add_dep(&mut self, from: CrateId, name: SmolStr, to: CrateId) {
|
pub fn add_dep(&mut self, from: CrateId, name: SmolStr, to: CrateId) {
|
||||||
if self.dfs(from, to) {
|
if self.dfs_find(from, to) {
|
||||||
panic!("Cycle dependencies found.")
|
panic!("Cycle dependencies found.")
|
||||||
}
|
}
|
||||||
self.arena.get_mut(&from).unwrap().add_dep(name, to)
|
self.arena.get_mut(&from).unwrap().add_dep(name, to)
|
||||||
|
@ -115,14 +115,14 @@ impl CrateGraph {
|
||||||
) -> impl Iterator<Item=&'a Dependency> + 'a {
|
) -> impl Iterator<Item=&'a Dependency> + 'a {
|
||||||
self.arena[&crate_id].dependencies.iter()
|
self.arena[&crate_id].dependencies.iter()
|
||||||
}
|
}
|
||||||
fn dfs(&self, target: CrateId, from: CrateId) -> bool {
|
fn dfs_find(&self, target: CrateId, from: CrateId) -> bool {
|
||||||
for dep in self.dependencies(from) {
|
for dep in self.dependencies(from) {
|
||||||
let crate_id = dep.crate_id();
|
let crate_id = dep.crate_id();
|
||||||
if crate_id == target {
|
if crate_id == target {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if self.arena.contains_key(&crate_id) {
|
if self.arena.contains_key(&crate_id) {
|
||||||
if self.dfs(target, crate_id) {
|
if self.dfs_find(target, crate_id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue