From dc02decd2a7ea30a2c220b8e5769e8a4d9160493 Mon Sep 17 00:00:00 2001 From: slbsh Date: Thu, 1 Aug 2024 23:03:29 +0200 Subject: [PATCH] fmt: cleanup clippy errors --- src/args.rs | 2 +- src/ast.rs | 4 ++-- src/main.rs | 8 +++++++- src/parser.rs | 2 +- src/report.rs | 6 ++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/args.rs b/src/args.rs index 05a4c61..324a722 100644 --- a/src/args.rs +++ b/src/args.rs @@ -156,7 +156,7 @@ impl Args { out.verbs.push(Box::leak(arg.into_boxed_str()) as &str); // drain remaining args - while let Some(arg) = args.next() { + for arg in args.by_ref() { out.verbs.push(Box::leak(arg.into_boxed_str()) as &str); } } diff --git a/src/ast.rs b/src/ast.rs index 3fab7c3..c8b3387 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -3,7 +3,7 @@ use std::fmt::{Display, Formatter}; pub struct Program { pub filename: &'static str, - pub stmts: Vec>, + pub stmts: Vec, } #[derive(Debug)] @@ -23,7 +23,7 @@ pub enum ASTKind { StringLiteral(String), CharLiteral(char), - Block(Vec>), + Block(Vec), TypeAnnotation(Type, Option>), diff --git a/src/main.rs b/src/main.rs index 18c101d..f30c856 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,10 @@ -#![forbid(clippy::all)] +#![forbid( + clippy::complexity, + clippy::suspicious, + clippy::correctness, + clippy::cargo +)] +#![allow(clippy::style, clippy::perf, clippy::pedantic, clippy::restriction)] #![allow(dead_code, unused)] use crate::lexer::Lexer; diff --git a/src/parser.rs b/src/parser.rs index 1b0d811..5a973da 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -114,7 +114,7 @@ impl<'t, 'contents> Parser<'t, 'contents> { } fn parse_block(&mut self, global: bool) -> Result { - let mut stmts = Vec::>::new(); + let mut stmts: Vec = Vec::new(); let until = if global { TokenKind::EOF } else { TokenKind::RBrace }; let start = self.current.span.clone(); diff --git a/src/report.rs b/src/report.rs index a378490..d7c68ee 100644 --- a/src/report.rs +++ b/src/report.rs @@ -217,10 +217,8 @@ impl Display for ReportFormatter<'_> { note.bright_black().italic() )?; } - } else { - if let Some(note) = &report.note { - writeln!(f, " {}", note.bright_black().italic())?; - } + } else if let Some(note) = &report.note { + writeln!(f, " {}", note.bright_black().italic())?; } }, None => {