From 60ddac977407b84c5fa597ae6eb500ed71b21384 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Tue, 19 Oct 2021 22:29:41 -0700 Subject: [PATCH] Rest of clippy lints --- schala-lang/codegen/src/lib.rs | 2 +- schala-lang/language/src/parsing/test.rs | 1 + schala-lang/language/src/typechecking.rs | 15 +++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/schala-lang/codegen/src/lib.rs b/schala-lang/codegen/src/lib.rs index b46f940..38ea171 100644 --- a/schala-lang/codegen/src/lib.rs +++ b/schala-lang/codegen/src/lib.rs @@ -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! { { diff --git a/schala-lang/language/src/parsing/test.rs b/schala-lang/language/src/parsing/test.rs index 9e9a40e..ab0d4d4 100644 --- a/schala-lang/language/src/parsing/test.rs +++ b/schala-lang/language/src/parsing/test.rs @@ -1,5 +1,6 @@ #![cfg(test)] #![allow(clippy::upper_case_acronyms)] +#![allow(clippy::vec_init_then_push)] use std::rc::Rc; diff --git a/schala-lang/language/src/typechecking.rs b/schala-lang/language/src/typechecking.rs index d743ded..538840a 100644 --- a/schala-lang/language/src/typechecking.rs +++ b/schala-lang/language/src/typechecking.rs @@ -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 { .. } => "".to_string() } } + */ fn from_string(string: &str) -> Option { Some(match string { @@ -287,12 +290,9 @@ impl<'a> TypeContext<'a> { fn decl(&mut self, decl: &Declaration) -> InferResult { 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) -> InferResult { 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, type_anno: &Option, _body: &Block) -> InferResult { let argument_types: InferResult> = 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) -> InferResult { + fn call(&mut self, f: &Expression, args: &[ InvocationArgument ]) -> InferResult { let tf = self.expr(f)?; let arg_types: InferResult> = 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 { let mut output = ty!(Unit); for statement in block.iter() {