Skip to content

Commit

Permalink
fix error formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Aug 28, 2024
1 parent a45c6e9 commit 4584120
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions crates/compilers/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,22 +558,31 @@ impl<L: Language, D: ParsedSource<Language = L>> Graph<D> {
idx: usize,
project: &Project<C, T>,
f: &mut W,
) -> std::result::Result<(), std::fmt::Error> {
self.format_node(idx, project, f)?;
write!(f, " imports:")?;
for dep in self.node_ids(idx).skip(1) {
write!(f, "\n ")?;
self.format_node(dep, project, f)?;
}

Ok(())
}

/// Formats a single node along with its version requirements.
fn format_node<W: std::fmt::Write, C: Compiler<Language = L>, T: ArtifactOutput>(
&self,
idx: usize,
project: &Project<C, T>,
f: &mut W,
) -> std::result::Result<(), std::fmt::Error> {
let node = self.node(idx);
write!(f, "{} ", utils::source_name(&node.path, &self.root).display())?;
write!(f, "{}", utils::source_name(&node.path, &self.root).display())?;
if let Some(req) = node.data.version_req() {
write!(f, "{req}")?;
write!(f, " {req}")?;
}
if let Some(req) = project.restrictions.get(&node.path).and_then(|r| r.version.as_ref()) {
write!(f, "{req}")?;
}
write!(f, " imports:")?;
for dep in self.node_ids(idx).skip(1) {
let dep = self.node(dep);
write!(f, "\n {} ", utils::source_name(&dep.path, &self.root).display())?;
if let Some(req) = dep.data.version_req() {
write!(f, "{req}")?;
}
write!(f, " {req}")?;
}

Ok(())
Expand Down

0 comments on commit 4584120

Please sign in to comment.