Handle dev-dependency cycles

This commit is contained in:
Lukas Wirth 2023-04-03 18:24:11 +02:00
parent 980c75bc91
commit a4c7a87755
3 changed files with 772 additions and 555 deletions

View file

@ -417,6 +417,11 @@ impl CrateGraph {
Ok(())
}
pub fn duplicate(&mut self, id: CrateId) -> CrateId {
let data = self[id].clone();
self.arena.alloc(data)
}
pub fn add_dep(
&mut self,
from: CrateId,
@ -612,6 +617,12 @@ impl ops::Index<CrateId> for CrateGraph {
}
}
impl ops::IndexMut<CrateId> for CrateGraph {
fn index_mut(&mut self, crate_id: CrateId) -> &mut CrateData {
&mut self.arena[crate_id]
}
}
impl CrateData {
fn add_dep(&mut self, dep: Dependency) {
self.dependencies.push(dep)