diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-01-22 16:48:00 +0900 |
|---|---|---|
| committer | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-01-22 16:48:00 +0900 |
| commit | a7d58edf270c25081c4f8a030ed03d22276a4abd (patch) | |
| tree | cdb4c38b92fde8ef5731e06c18501879720cd9c4 /clippy_lints/src | |
| parent | 3e74853d1f9893cf2a47f28b658711d8f9f97b6b (diff) | |
| download | rust-a7d58edf270c25081c4f8a030ed03d22276a4abd.tar.gz rust-a7d58edf270c25081c4f8a030ed03d22276a4abd.zip | |
Ignore macros with `!` operators in `eq_op`
Diffstat (limited to 'clippy_lints/src')
| -rw-r--r-- | clippy_lints/src/eq_op.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index e40b9de9239..01b04220a06 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -1,4 +1,6 @@ -use crate::utils::{implements_trait, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq}; +use crate::utils::{ + implements_trait, in_macro, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq, +}; use rustc_errors::Applicability; use rustc_hir::*; use rustc_lint::{LateContext, LateLintPass}; @@ -53,6 +55,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { if e.span.from_expansion() { return; } + let macro_with_not_op = |expr_kind: &ExprKind<'_>| { + if let ExprKind::Unary(_, ref expr) = *expr_kind { + in_macro(expr.span) + } else { + false + } + }; + if macro_with_not_op(&left.kind) || macro_with_not_op(&right.kind) { + return; + } if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) { span_lint( cx, |
