]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/eq_op.rs
Rollup merge of #83092 - petrochenkov:qspan, r=estebank
[rust.git] / clippy_lints / src / eq_op.rs
index 3201adbf9a0b60147bd8dd96cdb0025e082f9cbc..6308f6e2e7e9d6d8c825620ad644386dad8b5b6f 100644 (file)
@@ -1,10 +1,10 @@
 use crate::utils::{
-    eq_expr_value, higher, implements_trait, in_macro, is_copy, is_expn_of, multispan_sugg, snippet, span_lint,
-    span_lint_and_then,
+    ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, implements_trait, in_macro, is_copy, is_expn_of,
+    multispan_sugg, snippet, span_lint, span_lint_and_then,
 };
 use if_chain::if_chain;
 use rustc_errors::Applicability;
-use rustc_hir::{BinOp, BinOpKind, BorrowKind, Expr, ExprKind, StmtKind};
+use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, StmtKind};
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
@@ -102,7 +102,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
             if macro_with_not_op(&left.kind) || macro_with_not_op(&right.kind) {
                 return;
             }
-            if is_valid_operator(op) && eq_expr_value(cx, left, right) {
+            if is_useless_with_eq_exprs(higher::binop(op.node)) && eq_expr_value(cx, left, right) {
                 span_lint(
                     cx,
                     EQ_OP,
@@ -245,22 +245,3 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
         }
     }
 }
-
-fn is_valid_operator(op: BinOp) -> bool {
-    matches!(
-        op.node,
-        BinOpKind::Sub
-            | BinOpKind::Div
-            | BinOpKind::Eq
-            | BinOpKind::Lt
-            | BinOpKind::Le
-            | BinOpKind::Gt
-            | BinOpKind::Ge
-            | BinOpKind::Ne
-            | BinOpKind::And
-            | BinOpKind::Or
-            | BinOpKind::BitXor
-            | BinOpKind::BitAnd
-            | BinOpKind::BitOr
-    )
-}