diff options
| author | Eduardo Broto <ebroto@tutanota.com> | 2020-10-23 22:16:59 +0200 |
|---|---|---|
| committer | Eduardo Broto <ebroto@tutanota.com> | 2020-10-23 22:16:59 +0200 |
| commit | cdb555f4fcdb57741ffb59bd2b0e66af69ea0a85 (patch) | |
| tree | 5c9c37427427a7d7b95dc090c560f006a9b92efe /clippy_lints/src/copies.rs | |
| parent | fcde7683fe7ca10c83e5bc17f0969d2284affcd2 (diff) | |
| download | rust-cdb555f4fcdb57741ffb59bd2b0e66af69ea0a85.tar.gz rust-cdb555f4fcdb57741ffb59bd2b0e66af69ea0a85.zip | |
Merge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup
Diffstat (limited to 'clippy_lints/src/copies.rs')
| -rw-r--r-- | clippy_lints/src/copies.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 10a64769585..6c969c3ead0 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -1,4 +1,4 @@ -use crate::utils::{eq_expr_value, SpanlessEq, SpanlessHash}; +use crate::utils::{eq_expr_value, in_macro, SpanlessEq, SpanlessHash}; use crate::utils::{get_parent_expr, higher, if_sequence, snippet, span_lint_and_note, span_lint_and_then}; use rustc_data_structures::fx::FxHashMap; use rustc_hir::{Arm, Block, Expr, ExprKind, MatchSource, Pat, PatKind}; @@ -220,6 +220,10 @@ fn lint_same_fns_in_if_cond(cx: &LateContext<'_>, conds: &[&Expr<'_>]) { }; let eq: &dyn Fn(&&Expr<'_>, &&Expr<'_>) -> bool = &|&lhs, &rhs| -> bool { + // Do not lint if any expr originates from a macro + if in_macro(lhs.span) || in_macro(rhs.span) { + return false; + } // Do not spawn warning if `IFS_SAME_COND` already produced it. if eq_expr_value(cx, lhs, rhs) { return false; |
