From 4cac9786c527bf4f9e14bfc03e8b5adf5cef2b1d Mon Sep 17 00:00:00 2001 From: pmk21 Date: Tue, 31 Mar 2020 15:50:15 +0530 Subject: [PATCH] Skip single_match lints in macro rules --- clippy_lints/src/matches.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index a124bf8b8..20b793f95 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -447,6 +447,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Matches { #[rustfmt::skip] fn check_single_match(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) { if arms.len() == 2 && arms[0].guard.is_none() && arms[1].guard.is_none() { + if in_macro(expr.span) { + // Don't lint match expressions present in + // macro_rules! block + return; + } if let PatKind::Or(..) = arms[0].pat.kind { // don't lint for or patterns for now, this makes // the lint noisy in unnecessary situations