From 0dd4ae0a7ac0c247078df492469ff20b8a90c886 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 21 Aug 2021 16:38:51 +0200 Subject: Prune derives --- src/parse/mod.rs | 4 ++-- src/parse/parser.rs | 10 ---------- src/parse/scanner.rs | 7 ------- src/parse/tokens.rs | 11 ++--------- 4 files changed, 4 insertions(+), 28 deletions(-) (limited to 'src/parse') diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 37b65c04..649b4eb8 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -201,7 +201,7 @@ fn list_item(p: &mut Parser) -> SyntaxNode { let column = p.column(start); p.eat_assert(Token::Hyph); let body = tree_indented(p, column); - SyntaxNode::List(Box::new(ListItem { span: p.span_from(start), body })) + SyntaxNode::List(Box::new(ListNode { span: p.span_from(start), body })) } /// Parse a single enum item. @@ -210,7 +210,7 @@ fn enum_item(p: &mut Parser, number: Option) -> SyntaxNode { let column = p.column(start); p.eat_assert(Token::Numbering(number)); let body = tree_indented(p, column); - SyntaxNode::Enum(Box::new(EnumItem { + SyntaxNode::Enum(Box::new(EnumNode { span: p.span_from(start), number, body, diff --git a/src/parse/parser.rs b/src/parse/parser.rs index 83e77a6a..c035319d 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -1,4 +1,3 @@ -use std::fmt::{self, Debug, Formatter}; use std::ops::Range; use super::{TokenMode, Tokens}; @@ -28,7 +27,6 @@ pub struct Parser<'s> { } /// A logical group of tokens, e.g. `[...]`. -#[derive(Debug, Copy, Clone)] struct GroupEntry { /// The start index of the group. Used by `Parser::end_group` to return the /// group's full span. @@ -391,11 +389,3 @@ impl<'s> Parser<'s> { self.groups.iter().any(|g| g.kind == kind) } } - -impl Debug for Parser<'_> { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - let mut s = self.tokens.scanner(); - s.jump(self.next_start()); - write!(f, "Parser({}|{})", s.eaten(), s.rest()) - } -} diff --git a/src/parse/scanner.rs b/src/parse/scanner.rs index f893c4d3..8e3e4278 100644 --- a/src/parse/scanner.rs +++ b/src/parse/scanner.rs @@ -1,4 +1,3 @@ -use std::fmt::{self, Debug, Formatter}; use std::slice::SliceIndex; /// A featureful char-based scanner. @@ -153,12 +152,6 @@ impl<'s> Scanner<'s> { } } -impl Debug for Scanner<'_> { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!(f, "Scanner({}|{})", self.eaten(), self.rest()) - } -} - /// Whether this character denotes a newline. #[inline] pub fn is_newline(character: char) -> bool { diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs index 684e340e..91d3ab7f 100644 --- a/src/parse/tokens.rs +++ b/src/parse/tokens.rs @@ -1,11 +1,8 @@ -use std::fmt::{self, Debug, Formatter}; - use super::{is_newline, Scanner}; use crate::geom::{AngularUnit, LengthUnit}; use crate::syntax::*; /// An iterator over the tokens of a string of source code. -#[derive(Clone)] pub struct Tokens<'s> { s: Scanner<'s>, mode: TokenMode, @@ -481,12 +478,6 @@ impl<'s> Tokens<'s> { } } -impl Debug for Tokens<'_> { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!(f, "Tokens({}|{})", self.s.eaten(), self.s.rest()) - } -} - fn keyword(ident: &str) -> Option> { Some(match ident { "not" => Token::Not, @@ -512,6 +503,8 @@ fn keyword(ident: &str) -> Option> { #[cfg(test)] #[allow(non_snake_case)] mod tests { + use std::fmt::Debug; + use super::*; use Option::None; -- cgit v1.2.3