From fbc4569f96e9e2f4ed91a6480dc6fead924ed179 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 30 Oct 2024 19:26:19 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Fix=20cargo=20clippy=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit semver: chore --- src/lexer/mod.rs | 2 +- src/main.rs | 8 +++----- src/parser/expression/mod.rs | 2 +- src/parser/lookup.rs | 9 ++++----- src/parser/mod.rs | 9 +++------ 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index 464f5c1..1d1341e 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -190,7 +190,7 @@ impl<'de> Iterator for Lexer<'de> { let mut number = String::new(); number.push(c); while let Some(c) = self.remainder.chars().next() { - if c.is_digit(10) || c == '.' { + if c.is_ascii_digit() || c == '.' { number.push(c); self.remainder = &self.remainder[c.len_utf8()..]; self.byte_offset += c.len_utf8(); diff --git a/src/main.rs b/src/main.rs index e562d5f..16df000 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,7 @@ -use std::vec; - use lexer::{Lexer, TokenKind}; -use miette::{highlighters::Highlighter, LabeledSpan}; -use owo_colors::{colors, styles, OwoColorize, Style, Styled}; +use owo_colors::{Style, Styled}; use parser::Parser; +use std::vec; pub mod lexer; pub mod parser; @@ -50,7 +48,7 @@ struct SomHighlighterState {} impl miette::highlighters::Highlighter for SomHighlighter { fn start_highlighter_state<'h>( &'h self, - source: &dyn miette::SpanContents<'_>, + _source: &dyn miette::SpanContents<'_>, ) -> Box { Box::new(SomHighlighterState {}) } diff --git a/src/parser/expression/mod.rs b/src/parser/expression/mod.rs index f0b6f80..8850455 100644 --- a/src/parser/expression/mod.rs +++ b/src/parser/expression/mod.rs @@ -86,7 +86,7 @@ pub fn call<'de>( .expect(TokenKind::Comma, "expected a comma between arguments")?; } - let argument = parse(parser, BindingPower::None)?; + let argument = parse(parser, binding_power.clone())?; arguments.push(argument); } diff --git a/src/parser/lookup.rs b/src/parser/lookup.rs index d741218..e945550 100644 --- a/src/parser/lookup.rs +++ b/src/parser/lookup.rs @@ -1,11 +1,10 @@ -use crate::lexer::{TokenKind, TokenValue}; -use miette::Result; -use std::collections::HashMap; - use super::{ - ast::{BinaryOperator, Expression, Primitive, Statement}, + ast::{Expression, Primitive, Statement}, expression, statement, Parser, }; +use crate::lexer::TokenKind; +use miette::Result; +use std::collections::HashMap; #[derive(Debug, Clone, PartialEq, PartialOrd)] pub enum BindingPower { diff --git a/src/parser/mod.rs b/src/parser/mod.rs index f3bff49..d683647 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -1,8 +1,7 @@ -use crate::lexer::{Lexer, Token, TokenKind}; +use crate::lexer::Lexer; use ast::{Statement, Symbol}; -use lookup::{BindingPower, Lookup}; -use miette::{Context, Error, Result}; -use std::{borrow::Cow, collections::HashMap}; +use lookup::Lookup; +use miette::Result; pub mod ast; pub mod expression; @@ -10,7 +9,6 @@ pub mod lookup; pub mod statement; pub struct Parser<'de> { - source: &'de str, lexer: Lexer<'de>, lookup: Lookup<'de>, } @@ -18,7 +16,6 @@ pub struct Parser<'de> { impl<'de> Parser<'de> { pub fn new(input: &'de str) -> Self { Parser { - source: input, lexer: Lexer::new(input), lookup: Lookup::default(), }