Only lint ranges that really overlap

This commit is contained in:
Nadrieril
2023-12-29 19:21:43 +01:00
parent 6f6ba2571d
commit a24f4db41b
6 changed files with 137 additions and 115 deletions

View File

@@ -125,7 +125,9 @@ pub fn analyze_match<'p, 'tcx>(
let pat_column = PatternColumn::new(arms);
// Lint ranges that overlap on their endpoints, which is likely a mistake.
lint_overlapping_range_endpoints(cx, &pat_column)?;
if !report.overlapping_range_endpoints.is_empty() {
lint_overlapping_range_endpoints(cx, &report.overlapping_range_endpoints);
}
// Run the non_exhaustive_omitted_patterns lint. Only run on refutable patterns to avoid hitting
// `if let`s. Only run if the match is exhaustive otherwise the error is redundant.