clippy fix

This commit is contained in:
NotAFile 2022-01-05 02:11:13 +01:00
parent 6cc7b3bcee
commit 99369b8f38
4 changed files with 14 additions and 15 deletions

View File

@ -63,7 +63,7 @@ fn lower_expression(
expr: &parser::Expression,
) -> Result<String, CompileError> {
match expr {
parser::Expression::Ident(ident) => Ok(make_pubid(&ident)),
parser::Expression::Ident(ident) => Ok(make_pubid(ident)),
parser::Expression::Call(call) => {
let output_gen_id = module.make_genid("cell");
module.add_wire(rtlil::Wire::new(&output_gen_id, 1, None));
@ -98,7 +98,7 @@ fn lower_assignment(
module: &mut rtlil::Module,
assignment: parser::Assign,
) -> Result<(), CompileError> {
let target_id = make_pubid(&assignment.lhs);
let target_id = make_pubid(assignment.lhs);
let return_wire = lower_expression(ctx, module, &assignment.expr)?;
module.add_connection(target_id, return_wire);
Ok(())
@ -106,8 +106,8 @@ fn lower_assignment(
pub fn lower_module(pa_module: parser::Module) -> Result<String, CompileError> {
let mut writer = rtlil::ILWriter::new();
let mut ir_module = rtlil::Module::new(make_pubid(&pa_module.name));
let mut context = Context {
let mut ir_module = rtlil::Module::new(make_pubid(pa_module.name));
let context = Context {
callables: get_builtins()
.into_iter()
.map(|clb| (clb.name.to_owned(), clb))
@ -120,7 +120,7 @@ pub fn lower_module(pa_module: parser::Module) -> Result<String, CompileError> {
parser::PortDirection::Output => rtlil::PortOption::Output(idx as i32 + 1),
};
let wire = rtlil::Wire::new(
make_pubid(&port.net.name),
make_pubid(port.net.name),
port.net.width.unwrap_or(1) as u32,
Some(dir_option),
);

View File

@ -1,11 +1,10 @@
use std::ops::{RangeFrom, RangeTo};
use nom::{
character::complete::{char, one_of},
combinator::{map_res, recognize},
multi::{many0, many1},
sequence::{preceded, terminated},
AsChar, FindToken, InputIter, InputLength, Offset, Slice,
};
use crate::parser::{IResult, Span};
@ -19,7 +18,7 @@ pub fn hexadecimal(input: Span) -> IResult<Span, u64> {
many0(char('_')),
))),
),
|out: Span| u64::from_str_radix(&str::replace(&out.fragment(), "_", ""), 16),
|out: Span| u64::from_str_radix(&str::replace(out.fragment(), "_", ""), 16),
)(input)
}

View File

@ -4,7 +4,7 @@ mod literals;
mod parser;
mod rtlil;
use nom::error::convert_error;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
@ -29,7 +29,7 @@ fn main() {
let input = parser::Span::new(input);
let parsed = parser::parse(input);
match parsed {
Err(nom::Err::Error(err) | nom::Err::Failure(err)) => {
Err(nom::Err::Error(_err) | nom::Err::Failure(_err)) => {
// TODO: get this working again
// print!("{}", convert_error(input, err))
}

View File

@ -8,7 +8,7 @@ use nom::{
sequence::{delimited, pair, preceded, separated_pair, terminated, tuple},
};
use nom_locate::{position, LocatedSpan};
use nom_locate::{LocatedSpan};
// custom span type for nom_locate
pub type Span<'a> = LocatedSpan<&'a str>;
@ -166,7 +166,7 @@ fn call_item(input: Span) -> IResult<Span, Call> {
char(')'),
),
)),
|(name, args)| Call { name: name, args },
|(name, args)| Call { name, args },
)(input)
}
@ -175,7 +175,7 @@ fn expression(input: Span) -> IResult<Span, Expression> {
map(ws0(operation), |op| Expression::Operation(Box::new(op))),
map(ws0(call_item), |call| Expression::Call(Box::new(call))),
map(ws0(identifier), |ident| {
Expression::Ident((*ident.fragment()).into())
Expression::Ident(*ident.fragment())
}),
))(input)
}
@ -189,7 +189,7 @@ fn assign_statement(input: Span) -> IResult<Span, Statement> {
separated_pair(ws0(identifier), char('='), ws0(expression)),
|(lhs, expr)| {
Statement::Assign(Assign {
lhs: (*lhs.fragment()).into(),
lhs: (*lhs.fragment()),
expr,
})
},
@ -214,7 +214,7 @@ pub fn module(input: Span) -> IResult<Span, Module> {
)),
)),
|(_, name, ports, statements)| Module {
name: (*name.fragment()).into(),
name: (*name.fragment()),
ports,
statements,
},