manual_range_patterns: Delay macro check.

This commit is contained in:
Jason Newcomb 2024-06-13 02:32:04 -04:00
parent 2309f8e4a1
commit 44f87e8cc1

View File

@ -76,14 +76,11 @@ fn min(self, other: Self) -> Self {
impl LateLintPass<'_> for ManualRangePatterns {
fn check_pat(&mut self, cx: &LateContext<'_>, pat: &'_ rustc_hir::Pat<'_>) {
if in_external_macro(cx.sess(), pat.span) {
return;
}
// a pattern like 1 | 2 seems fine, lint if there are at least 3 alternatives
// or at least one range
if let PatKind::Or(pats) = pat.kind
&& (pats.len() >= 3 || pats.iter().any(|p| matches!(p.kind, PatKind::Range(..))))
&& !in_external_macro(cx.sess(), pat.span)
{
let mut min = Num::dummy(i128::MAX);
let mut max = Num::dummy(i128::MIN);