From 47c0a3ca296a9b775275c2c7118a172b9f0bcc54 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 8 Apr 2019 18:23:55 +0200 Subject: clippy --- dhall_core/src/core.rs | 14 +++++++------- dhall_core/src/lib.rs | 3 ++- dhall_core/src/parser.rs | 6 +++--- dhall_core/src/printer.rs | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'dhall_core') diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index 89506ec..39dea37 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -25,7 +25,7 @@ pub struct NaiveDouble(f64); impl PartialEq for NaiveDouble { fn eq(&self, other: &Self) -> bool { - return self.0.to_bits() == other.0.to_bits(); + self.0.to_bits() == other.0.to_bits() } } @@ -283,7 +283,7 @@ impl Expr { F: Fn(&A) -> B, { let recurse = |e: &Expr| -> Expr { e.map_embed(map_embed) }; - self.map_shallow(recurse, |x| x.clone(), map_embed, |x| x.clone()) + self.map_shallow(recurse, S::clone, map_embed, Label::clone) } #[inline(always)] @@ -315,7 +315,7 @@ impl Expr { F: Fn(&Label) -> Label, { let recurse = |e: &Self| -> Self { e.map_label(map_label) }; - self.map_shallow(recurse, |x| x.clone(), |x| x.clone(), map_label) + self.map_shallow(recurse, S::clone, A::clone, map_label) } #[inline(always)] @@ -333,10 +333,10 @@ impl Expr> { match self { ExprF::Embed(e) => e.clone(), e => e.map_shallow( - |e| e.squash_embed(), - |x| x.clone(), + >>::squash_embed, + S::clone, |_| unreachable!(), - |x| x.clone(), + Label::clone, ), } } @@ -368,7 +368,7 @@ impl ExprF { fn opt(x: &Option) -> Option<&T> { x.as_ref() } - fn vec(x: &Vec) -> Vec<&T> { + fn vec(x: &[T]) -> Vec<&T> { x.iter().collect() } fn btmap(x: &BTreeMap) -> BTreeMap<&L, &SE> { diff --git a/dhall_core/src/lib.rs b/dhall_core/src/lib.rs index 2042b04..9fddd1f 100644 --- a/dhall_core/src/lib.rs +++ b/dhall_core/src/lib.rs @@ -4,7 +4,8 @@ #![allow( clippy::many_single_char_names, clippy::should_implement_trait, - clippy::new_without_default + clippy::new_without_default, + clippy::type_complexity )] mod core; diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs index 41a2ce7..9d77f52 100644 --- a/dhall_core/src/parser.rs +++ b/dhall_core/src/parser.rs @@ -180,7 +180,7 @@ macro_rules! make_parser { ); ($( $submac:ident!( $name:ident<$o:ty> $($args:tt)* ); )*) => ( - #[allow(non_camel_case_types, dead_code)] + #[allow(non_camel_case_types, dead_code, clippy::large_enum_variant)] #[derive(Debug)] enum ParsedValue<'a> { $( $name($o), )* @@ -283,7 +283,7 @@ make_parser! { [label(l)] => { if crate::Builtin::parse(&String::from(&l)).is_some() { Err( - format!("Builtin names are not allowed as bound variables") + "Builtin names are not allowed as bound variables".to_string() )? } l @@ -323,7 +323,7 @@ make_parser! { // "uXXXX" use std::convert::TryFrom; let c = u16::from_str_radix(&s[1..5], 16).unwrap(); - let c = char::try_from(c as u32).unwrap(); + let c = char::try_from(u32::from(c)).unwrap(); std::iter::once(c).collect() } } diff --git a/dhall_core/src/printer.rs b/dhall_core/src/printer.rs index 746b863..4f56fb6 100644 --- a/dhall_core/src/printer.rs +++ b/dhall_core/src/printer.rs @@ -318,7 +318,7 @@ impl Display for NaiveDouble { f.write_str("NaN") } else { let s = format!("{}", v); - if s.contains("e") || s.contains(".") { + if s.contains('e') || s.contains('.') { f.write_str(&s) } else { write!(f, "{}.0", s) -- cgit v1.2.3