From a896e66ccaa86068f12bf266b5518e037876289b Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Mon, 20 Nov 2023 10:29:08 +0100 Subject: [PATCH] run cargo clippy --fix --- src/error/mod.rs | 20 ++++++++++---------- src/namespace/mod.rs | 4 ++-- src/namespace/typedef.rs | 6 +++--- src/syntax/check.rs | 2 +- src/syntax/check/test.rs | 14 +++++++------- src/syntax/mod.rs | 13 +++++-------- src/typed.rs | 4 ++-- 7 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/error/mod.rs b/src/error/mod.rs index 1c20444..8a04587 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -1,4 +1,4 @@ -use std::cell::RefCell; + use codespan_reporting::{ diagnostic::{Diagnostic, Label}, @@ -49,35 +49,35 @@ impl Errors { pub fn into_diag( &self, file_id: usize, - file_db: &SimpleFiles<&str, String>, + _file_db: &SimpleFiles<&str, String>, ) -> Diagnostic { let Errors { kind, locs } = self; match kind { - ErrorKind::InvalidToken => simple_diag(locs.to_vec(), file_id, "invalid tokens"), + ErrorKind::InvalidToken => simple_diag(locs.clone(), file_id, "invalid tokens"), ErrorKind::SyntaxError(syntax_error) => match syntax_error { SyntaxErrorKind::MissingStreamer => simple_diag( - locs.to_vec(), + locs.clone(), file_id, "pipeline is missing an input provider", ), SyntaxErrorKind::MissingSink => { - simple_diag(locs.to_vec(), file_id, "pipeline is missing a sink") + simple_diag(locs.clone(), file_id, "pipeline is missing a sink") } SyntaxErrorKind::MissingFilter => { - simple_diag(locs.to_vec(), file_id, "missing filters in pipeline") + simple_diag(locs.clone(), file_id, "missing filters in pipeline") } SyntaxErrorKind::LiteralAsSink => { - simple_diag(locs.to_vec(), file_id, "pipelines can't end in a literal") + simple_diag(locs.clone(), file_id, "pipelines can't end in a literal") } SyntaxErrorKind::LiteralAsFilter => { - simple_diag(locs.to_vec(), file_id, "literals can't filter data") + simple_diag(locs.clone(), file_id, "literals can't filter data") } SyntaxErrorKind::LiteralWithArgs => { - simple_diag(locs.to_vec(), file_id, "literals can't take arguments") + simple_diag(locs.clone(), file_id, "literals can't take arguments") } }, - ErrorKind::CommandNotFound => simple_diag(locs.to_vec(), file_id, "command not found"), + ErrorKind::CommandNotFound => simple_diag(locs.clone(), file_id, "command not found"), } } } diff --git a/src/namespace/mod.rs b/src/namespace/mod.rs index 1a95363..326bd6b 100644 --- a/src/namespace/mod.rs +++ b/src/namespace/mod.rs @@ -94,8 +94,8 @@ impl GlobalNamespace { } else { self.commands.borrow_mut().push(InternalCommand { name: name.to_owned(), - input: input.map(|def| def.into()), - output: output.map(|def| def.into()), + input: input.map(std::convert::Into::into), + output: output.map(std::convert::Into::into), }); let id = self.traits.borrow().len() - 1; let _ = self diff --git a/src/namespace/typedef.rs b/src/namespace/typedef.rs index 279a8be..0bb305e 100644 --- a/src/namespace/typedef.rs +++ b/src/namespace/typedef.rs @@ -30,12 +30,12 @@ impl<'a> TypeDef<'a> { ), }, InternalTypeDef::List(list) => TypeDef::List( - list.into_iter() + list.iter() .map(|def| Self::from_internal(ns, def)) .collect(), ), InternalTypeDef::Record(rec) => TypeDef::Record( - rec.into_iter() + rec.iter() .map(|(name, def)| (name.clone(), Self::from_internal(ns, def))) .collect(), ), @@ -112,7 +112,7 @@ impl From> for InternalTypeDef { match value { TypeDef::Type(val) => Self::Single(TypeNamespaceId::Types(val.id)), TypeDef::Trait(val) => Self::Single(TypeNamespaceId::Traits(val.id)), - TypeDef::List(list) => Self::List(list.into_iter().map(|def| def.into()).collect()), + TypeDef::List(list) => Self::List(list.into_iter().map(std::convert::Into::into).collect()), TypeDef::Record(rec) => Self::Record( rec.into_iter() .map(|(name, typ)| (name, typ.into())) diff --git a/src/syntax/check.rs b/src/syntax/check.rs index 5b30ccf..4f2c701 100644 --- a/src/syntax/check.rs +++ b/src/syntax/check.rs @@ -88,7 +88,7 @@ fn check_missing_filters(syntax: &[PipelineElement]) -> Result<(), Vec Result, Vec = Vec::new(); - for (tok, span) in lexer.spanned().into_iter() { + for (tok, span) in lexer.spanned() { if let Ok(tok) = tok { match tok { Token::Pipe => { @@ -52,10 +52,7 @@ pub fn parse_syntax(input: &str) -> Result, Vec Result, Vec {} } } else { - errs.push(span) + errs.push(span); } } @@ -110,5 +107,5 @@ pub fn parse_syntax(input: &str) -> Result, Vec {}