clippy fix

This commit is contained in:
NotAFile 2022-02-03 00:08:45 +01:00
parent 01fa26742e
commit dfae432055
3 changed files with 5 additions and 14 deletions

View File

@ -44,12 +44,12 @@ where
} }
} }
fn or(mut self, mut other: Self) -> Self { fn or(self, mut other: Self) -> Self {
let self_first = self.errors.first(); let self_first = self.errors.first();
let other_first = other.errors.first(); let other_first = other.errors.first();
match (self_first, other_first) { match (self_first, other_first) {
(Some((is, ErrorKind::Token(s))), Some((io, ErrorKind::Token(o)))) => { (Some((_is, ErrorKind::Token(s))), Some((io, ErrorKind::Token(o)))) => {
let combined_kind = ErrorKind::Tokens(vec![s.clone(), o.clone()]); let combined_kind = ErrorKind::Tokens(vec![*s, *o]);
other.errors[0] = (io.clone(), combined_kind); other.errors[0] = (io.clone(), combined_kind);
other other
} }

View File

@ -6,15 +6,6 @@ pub mod module;
pub mod proc; pub mod proc;
pub mod tokens; pub mod tokens;
use nom::{
branch::alt,
bytes::complete::tag,
character::complete::{alpha1, alphanumeric1, multispace0},
combinator::{map, opt, recognize},
error::{ErrorKind, ParseError},
multi::{many0, separated_list0},
sequence::{delimited, pair, preceded, separated_pair, tuple},
};
use nom_locate::LocatedSpan; use nom_locate::LocatedSpan;
// custom span type for nom_locate // custom span type for nom_locate
@ -29,7 +20,7 @@ pub use crate::parser::declaration::{
}; };
pub use crate::parser::expression::{expression, Call, Expression, Operation}; pub use crate::parser::expression::{expression, Call, Expression, Operation};
pub use crate::parser::module::{module, Module, ModuleItem, PortDirection}; pub use crate::parser::module::{module, Module, ModuleItem, PortDirection};
use crate::parser::tokens::{token, TokenKind as tk, TokenSpan}; use crate::parser::tokens::TokenSpan;
pub fn parse(input: TokenSpan) -> IResult<TokenSpan, Module> { pub fn parse(input: TokenSpan) -> IResult<TokenSpan, Module> {
module(input) module(input)

View File

@ -133,7 +133,7 @@ impl InputPos for TokenSpan<'_> {
pub fn token<'a>(kind: TokenKind) -> impl FnMut(TokenSpan<'a>) -> IResult<TokenSpan, &Token> { pub fn token<'a>(kind: TokenKind) -> impl FnMut(TokenSpan<'a>) -> IResult<TokenSpan, &Token> {
move |input: TokenSpan| { move |input: TokenSpan| {
let next = &input.rest[0]; let next = &input.rest[0];
let kind = kind.clone(); let kind = kind;
if next.kind == kind { if next.kind == kind {
let rest = TokenSpan::with_pos(&input.rest[1..], input.pos + 1); let rest = TokenSpan::with_pos(&input.rest[1..], input.pos + 1);
Ok((rest, next)) Ok((rest, next))