From 1798baa9d3bf25d999b31360ed34aec440da270b Mon Sep 17 00:00:00 2001 From: NotAFile Date: Wed, 2 Feb 2022 01:03:03 +0100 Subject: [PATCH] clippy fix --- src/builtin_cells.rs | 6 +++--- src/frontend.rs | 2 +- src/main.rs | 1 - src/parser.rs | 6 +++--- src/parser/error.rs | 2 +- src/parser/module.rs | 14 ++++++-------- src/parser/proc.rs | 8 +++----- src/parser/tokens.rs | 5 ++--- 8 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/builtin_cells.rs b/src/builtin_cells.rs index e60da9d..34fb0e3 100644 --- a/src/builtin_cells.rs +++ b/src/builtin_cells.rs @@ -1,4 +1,4 @@ -use crate::frontend::types::{Type, TypeStruct}; +use crate::frontend::types::TypeStruct; use crate::frontend::Callable; use crate::rtlil; use crate::rtlil::SigSpec; @@ -39,7 +39,7 @@ fn instantiate_binop(celltype: &str, id: &str, args: &[SigSpec], ret: &SigSpec) cell } -fn make_binop_callable<'ctx>(name: &str, celltype: &'static str) -> Callable<'ctx> { +fn make_binop_callable<'ctx>(name: &str, _celltype: &'static str) -> Callable<'ctx> { // FIXME: CRIMES CRIMES CRIMES let logic_type: &'static TypeStruct = Box::leak(Box::new(TypeStruct::logic_infer())); let args = vec![ @@ -53,7 +53,7 @@ fn make_binop_callable<'ctx>(name: &str, celltype: &'static str) -> Callable<'ct } } -fn make_unnop_callable<'ctx>(name: &str, celltype: &'static str) -> Callable<'ctx> { +fn make_unnop_callable<'ctx>(name: &str, _celltype: &'static str) -> Callable<'ctx> { // FIXME: CRIMES CRIMES CRIMES let logic_type: &'static TypeStruct = Box::leak(Box::new(TypeStruct::logic_infer())); let args = vec![(Some("A".to_owned()), logic_type)]; diff --git a/src/frontend.rs b/src/frontend.rs index 51a98de..00cba25 100644 --- a/src/frontend.rs +++ b/src/frontend.rs @@ -255,7 +255,7 @@ fn lower_expression( })); } - let cell_id = module.make_genid(&callable.name()); + let cell_id = module.make_genid(callable.name()); let output_gen_id = format!("{}$out", &cell_id); module.add_wire(rtlil::Wire::new(&output_gen_id, TODO_WIDTH, None)); diff --git a/src/main.rs b/src/main.rs index 03b7a85..97af334 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,6 @@ use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; -use ariadne::Source; use structopt::StructOpt; #[derive(Debug, StructOpt)] diff --git a/src/parser.rs b/src/parser.rs index 6aa7cc7..875fcc0 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -7,11 +7,11 @@ pub mod tokens; use nom::{ branch::alt, bytes::complete::tag, - character::complete::{alpha1, alphanumeric1, char, multispace0, u64 as decimal}, + character::complete::{alpha1, alphanumeric1, multispace0}, combinator::{map, opt, recognize}, error::{ErrorKind, ParseError}, multi::{many0, separated_list0}, - sequence::{delimited, pair, preceded, separated_pair, terminated, tuple}, + sequence::{delimited, pair, preceded, separated_pair, tuple}, }; use nom_greedyerror::GreedyError; use nom_locate::LocatedSpan; @@ -114,7 +114,7 @@ fn declaration(i: TokenSpan) -> IResult { separated_pair(token(tk::Ident), token(tk::Colon), typename), opt(preceded(token(tk::Assign), token(tk::Number))), )), - |((ident, typ), value)| NetDecl { + |((ident, typ), _value)| NetDecl { name: ident.span(), typ, value: None, diff --git a/src/parser/error.rs b/src/parser/error.rs index 8a9771c..1c37f1e 100644 --- a/src/parser/error.rs +++ b/src/parser/error.rs @@ -6,7 +6,7 @@ fn span_to_range(input: Span) -> std::ops::Range { input.position()..(input.position() + input.len()) } -pub fn convert_error(input: Span, e: IErr) -> Report { +pub fn convert_error(_input: Span, e: IErr) -> Report { let mut labels = Vec::new(); for err in e.errors { let label = match err.1 { diff --git a/src/parser/module.rs b/src/parser/module.rs index 005079a..e5672fd 100644 --- a/src/parser/module.rs +++ b/src/parser/module.rs @@ -1,18 +1,16 @@ use nom::{ branch::alt, - bytes::complete::tag, - character::complete::{char, multispace1}, - combinator::{consumed, map}, + combinator::map, error::context, multi::{many0, separated_list0}, - sequence::{delimited, preceded, terminated, tuple}, + sequence::{delimited, preceded, tuple}, }; use crate::parser::{ - assign_statement, declaration, identifier, + assign_statement, declaration, proc::{proc_block, ProcBlock}, - tokens::{token, Token, TokenKind as tk, TokenSpan}, - typename, ws0, Assign, IResult, NetDecl, Span, + tokens::{token, TokenKind as tk, TokenSpan}, + typename, Assign, IResult, NetDecl, Span, }; #[derive(Debug)] @@ -76,7 +74,7 @@ pub fn module(input: TokenSpan) -> IResult { preceded(token(tk::RArrow), typename), delimited(token(tk::LBrace), many0(module_item), token(tk::RBrace)), )), - |(_, name, inputs, ret, items)| Module { + |(_, name, inputs, _ret, items)| Module { // TODO: bring back returns name: name.span(), ports: inputs, diff --git a/src/parser/proc.rs b/src/parser/proc.rs index 1ac0796..dbfd7a0 100644 --- a/src/parser/proc.rs +++ b/src/parser/proc.rs @@ -1,7 +1,5 @@ use nom::{ branch::alt, - bytes::complete::tag, - character::complete::char, combinator::map, error::context, multi::{many1, separated_list1}, @@ -9,9 +7,9 @@ use nom::{ }; use crate::parser::{ - assign_statement, expression, identifier, - tokens::{token, Token, TokenKind as tk, TokenSpan}, - ws0, Assign, Expression, IResult, Span, + assign_statement, expression, + tokens::{token, TokenKind as tk, TokenSpan}, + Assign, Expression, IResult, Span, }; #[derive(Debug)] diff --git a/src/parser/tokens.rs b/src/parser/tokens.rs index f6ee473..b360669 100644 --- a/src/parser/tokens.rs +++ b/src/parser/tokens.rs @@ -10,7 +10,6 @@ use nom::{ multi::many0, }; use std::fmt; -use std::io; pub struct Token<'a> { span: Span<'a>, @@ -100,8 +99,8 @@ impl nom::InputTake for TokenSpan<'_> { fn take_split(&self, count: usize) -> (Self, Self) { let (head, tail) = &self.rest.split_at(count); ( - TokenSpan::with_pos(&head, self.pos), - TokenSpan::with_pos(&tail, self.pos + count), + TokenSpan::with_pos(head, self.pos), + TokenSpan::with_pos(tail, self.pos + count), ) } }