fix: avoid infinite recursion bugs

This commit is contained in:
Shunsuke Shibayama 2023-03-22 01:28:22 +09:00
parent 2a0998f0cd
commit b318395a32
10 changed files with 128 additions and 48 deletions

View file

@ -22,6 +22,7 @@ impl ModuleGraph {
}
pub fn get_node(&self, path: &Path) -> Option<&Node<PathBuf, ()>> {
let path = normalize_path(path.to_path_buf());
self.0.iter().find(|n| n.id == path)
}
@ -34,6 +35,7 @@ impl ModuleGraph {
}
pub fn inc_ref(&mut self, referrer: &Path, depends_on: PathBuf) {
let referrer = normalize_path(referrer.to_path_buf());
let depends_on = normalize_path(depends_on);
if let Some(node) = self.0.iter_mut().find(|n| n.id == referrer) {
if referrer == depends_on {