Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4cac978

Browse files
committed
Skip single_match lints in macro rules
1 parent 793403a commit 4cac978

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

clippy_lints/src/matches.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Matches {
447447
#[rustfmt::skip]
448448
fn check_single_match(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) {
449449
if arms.len() == 2 && arms[0].guard.is_none() && arms[1].guard.is_none() {
450+
if in_macro(expr.span) {
451+
// Don't lint match expressions present in
452+
// macro_rules! block
453+
return;
454+
}
450455
if let PatKind::Or(..) = arms[0].pat.kind {
451456
// don't lint for or patterns for now, this makes
452457
// the lint noisy in unnecessary situations

0 commit comments

Comments
 (0)