Skip to content

Commit

Permalink
Fix trait's Display implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Nak committed Nov 15, 2022
1 parent 2ea0ee0 commit 53b3926
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crates/parser/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,21 +691,24 @@ impl fmt::Display for ConstantDecl {

impl fmt::Display for Trait {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
writeln!(f, "trait {}:", self.name.kind)?;

Ok(())
if self.pub_qual.is_some() {
write!(f, "pub ")?;
}
write!(f, "trait {} {{", self.name.kind)?;
write_nodes_line_wrapped(&mut indented(f), &self.functions)?;
write!(f, "}}")
}
}

impl fmt::Display for Impl {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
writeln!(
write!(
f,
"impl {} for {}",
"impl {} for {} {{",
self.impl_trait.kind, self.receiver.kind
)?;

Ok(())
write_nodes_line_wrapped(&mut indented(f), &self.functions)?;
write!(f, "}}")
}
}

Expand Down Expand Up @@ -1306,7 +1309,6 @@ impl InfixBindingPower for BoolOperator {
}
}
}

impl InfixBindingPower for BinOperator {
fn infix_binding_power(&self) -> (u8, u8) {
use BinOperator::*;
Expand Down

0 comments on commit 53b3926

Please sign in to comment.