From 66b855c30b590e8c3140375f9e5afc71ce0b2775 Mon Sep 17 00:00:00 2001 From: logan-dev-oss Date: Fri, 17 Apr 2020 10:12:30 +0200 Subject: [PATCH] Integrate more idiomatic rust changes. --- clippy_lints/src/precedence.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index 61c3cc37ae03..cc783baa6872 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -104,14 +104,16 @@ impl EarlyLintPass for Precedence { if let ExprKind::Unary(UnOp::Neg, ref rhs) = expr.kind { if let ExprKind::MethodCall(ref path_segment, ref args) = rhs.kind { + let path_segment_str = path_segment.ident.name.as_str(); if let Some(slf) = args.first() { if let ExprKind::Lit(ref lit) = slf.kind { match lit.kind { LitKind::Int(..) | LitKind::Float(..) => { - for &odd_function in &ODD_FUNCTIONS_WHITELIST { - if odd_function == &*path_segment.ident.name.as_str() { - return; - } + if ODD_FUNCTIONS_WHITELIST + .iter() + .any(|odd_function| **odd_function == *path_segment_str) + { + return; } let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg(