assert!(prev.is_none());
crate_id
}
- // FIXME: check that we don't have cycles here.
- // Just a simple depth first search from `to` should work,
- // the graph is small.
pub fn add_dep(&mut self, from: CrateId, name: SmolStr, to: CrateId) {
+ let mut visited = FxHashSet::default();
+ if self.dfs_find(from, to, &mut visited) {
+ panic!("Cycle dependencies found.")
+ }
self.arena.get_mut(&from).unwrap().add_dep(name, to)
}
+ pub fn is_empty(&self) -> bool {
+ self.arena.is_empty()
+ }
pub fn crate_root(&self, crate_id: CrateId) -> FileId {
self.arena[&crate_id].file_id
}