diff --git a/compiler/syntax/src/token_kind.rs b/compiler/syntax/src/token_kind.rs index f4a1c54a..1092b8e8 100644 --- a/compiler/syntax/src/token_kind.rs +++ b/compiler/syntax/src/token_kind.rs @@ -21,14 +21,7 @@ pub enum LiteralKind { impl fmt::Display for LiteralKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let label = match self { - LiteralKind::Int => "Int", - LiteralKind::Float => "Float", - LiteralKind::Str => "Str", - LiteralKind::Bool => "Bool", - LiteralKind::Null => "Null", - }; - write!(f, "{}", label) + fmt::Debug::fmt(self, f) } } @@ -47,13 +40,7 @@ pub enum NumericLiteralKind { impl fmt::Display for NumericLiteralKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let label = match self { - NumericLiteralKind::Decimal => "Decimal", - NumericLiteralKind::Hex => "Hex", - NumericLiteralKind::Binary => "Binary", - NumericLiteralKind::Octal => "Octal", - }; - write!(f, "{}", label) + fmt::Debug::fmt(self, f) } } @@ -791,18 +778,7 @@ impl fmt::Display for TokenKind { if let Some(lexeme) = self.static_lexeme() { write!(f, "'{}'", lexeme) } else { - let label = match self { - TokenKind::Identifier => "Identifier", - TokenKind::IntLiteral => "Integer Literal", - TokenKind::FloatLiteral => "Float Literal", - TokenKind::StringLiteral => "String Literal", - TokenKind::FStringText => "f-string segment", - TokenKind::Newline => "Newline", - TokenKind::Eof => "EOF", - TokenKind::Error => "Error", - _ => "Unknown Token", - }; - write!(f, "{}", label) + fmt::Debug::fmt(self, f) } } }