diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index 702931c0532..3b2ef4e8bb2 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -1,7 +1,8 @@ use crate::syntax::ast::*; use crate::rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use crate::rustc::{declare_tool_lint, lint_array}; -use crate::utils::span_lint; +use crate::utils::{in_macro, span_lint}; + /// **What it does:** Checks for unnecessary double parentheses. /// @@ -33,6 +34,10 @@ impl LintPass for DoubleParens { impl EarlyLintPass for DoubleParens { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { + if in_macro(expr.span) { + return; + } + match expr.node { ExprKind::Paren(ref in_paren) => match in_paren.node { ExprKind::Paren(_) | ExprKind::Tup(_) => { diff --git a/tests/ui/double_parens.rs b/tests/ui/double_parens.rs index 8d81ee16fe9..c217972fa6a 100644 --- a/tests/ui/double_parens.rs +++ b/tests/ui/double_parens.rs @@ -48,4 +48,10 @@ fn method_unit_ok(x: DummyStruct) { x.dummy_method(()); } +// Issue #3206 +fn inside_macro() { + assert_eq!((1, 2), (1, 2), "Error"); + assert_eq!(((1, 2)), (1, 2), "Error"); +} + fn main() {} diff --git a/tests/ui/double_parens.stderr b/tests/ui/double_parens.stderr index a6a29eeb063..3e38db730e0 100644 --- a/tests/ui/double_parens.stderr +++ b/tests/ui/double_parens.stderr @@ -30,5 +30,11 @@ error: Consider removing unnecessary double parentheses 32 | (()) | ^^^^ -error: aborting due to 5 previous errors +error: Consider removing unnecessary double parentheses + --> $DIR/double_parens.rs:54:16 + | +54 | assert_eq!(((1, 2)), (1, 2), "Error"); + | ^^^^^^^^ + +error: aborting due to 6 previous errors