Rest of clippy lints

This commit is contained in:
Greg Shuflin 2021-10-19 22:29:41 -07:00
parent ae6a79077f
commit 60ddac9774
3 changed files with 11 additions and 7 deletions

View File

@ -15,7 +15,7 @@ struct RecursiveDescentFn {
impl Fold for RecursiveDescentFn {
fn fold_item_fn(&mut self, mut i: syn::ItemFn) -> syn::ItemFn {
let box block = i.block;
let ref ident = i.ident;
let ident = &i.ident;
let new_block: syn::Block = parse_quote! {
{

View File

@ -1,5 +1,6 @@
#![cfg(test)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::vec_init_then_push)]
use std::rc::Rc;

View File

@ -1,5 +1,4 @@
use std::rc::Rc;
use std::fmt::Write;
use std::convert::TryFrom;
use ena::unify::{UnifyKey, InPlaceUnificationTable, UnificationTable, EqUnifyValue};
@ -79,6 +78,7 @@ pub enum TypeConst {
}
impl TypeConst {
/*
#[allow(dead_code)]
pub fn to_string(&self) -> String {
use self::TypeConst::*;
@ -92,6 +92,7 @@ impl TypeConst {
Ordering => "Ordering".to_string(),
}
}
*/
}
impl EqUnifyValue for TypeConst { }
@ -110,6 +111,7 @@ macro_rules! ty {
//TODO find a better way to capture the to/from string logic
impl Type {
/*
#[allow(dead_code)]
pub fn to_string(&self) -> String {
use self::Type::*;
@ -131,6 +133,7 @@ impl Type {
Compound { .. } => "<some compound type>".to_string()
}
}
*/
fn from_string(string: &str) -> Option<Type> {
Some(match string {
@ -287,12 +290,9 @@ impl<'a> TypeContext<'a> {
fn decl(&mut self, decl: &Declaration) -> InferResult<Type> {
use self::Declaration::*;
match decl {
Binding { name, expr, .. } => {
if let Binding { name, expr, .. } = decl {
let ty = self.expr(expr)?;
self.variable_map.insert(name.clone(), ty);
},
_ => (),
}
Ok(ty!(Unit))
}
@ -365,6 +365,7 @@ impl<'a> TypeContext<'a> {
}
}
#[allow(clippy::ptr_arg)]
fn handle_simple_if(&mut self, expr: &Expression, then_clause: &Block, else_clause: &Option<Block>) -> InferResult<Type> {
let t1 = self.expr(expr)?;
let t2 = self.block(then_clause)?;
@ -377,6 +378,7 @@ impl<'a> TypeContext<'a> {
self.unify(t2, t3)
}
#[allow(clippy::ptr_arg)]
fn lambda(&mut self, params: &Vec<FormalParam>, type_anno: &Option<TypeIdentifier>, _body: &Block) -> InferResult<Type> {
let argument_types: InferResult<Vec<Type>> = params.iter().map(|param: &FormalParam| {
if let FormalParam { anno: Some(type_identifier), .. } = param {
@ -394,7 +396,7 @@ impl<'a> TypeContext<'a> {
Ok(ty!(argument_types, ret_type))
}
fn call(&mut self, f: &Expression, args: &Vec<InvocationArgument>) -> InferResult<Type> {
fn call(&mut self, f: &Expression, args: &[ InvocationArgument ]) -> InferResult<Type> {
let tf = self.expr(f)?;
let arg_types: InferResult<Vec<Type>> = args.iter().map(|ex| self.invoc(ex)).collect();
let arg_types = arg_types?;
@ -414,6 +416,7 @@ impl<'a> TypeContext<'a> {
})
}
#[allow(clippy::ptr_arg)]
fn block(&mut self, block: &Block) -> InferResult<Type> {
let mut output = ty!(Unit);
for statement in block.iter() {