about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-01-12 11:29:06 +0000
committerbors <bors@rust-lang.org>2024-01-12 11:29:06 +0000
commit174e73a3f6df6f96ab453493796e461164dea94a (patch)
treec32961a724a15c7a6ea68ef2003f97fef216af0c /compiler/rustc_pattern_analysis/src/lib.rs
parentbfd799f1a5a86d16e6b8caa2857bcb4aac6e0174 (diff)
parenta24f4db41ba629a2477d6d332585faf5610c9210 (diff)
downloadrust-174e73a3f6df6f96ab453493796e461164dea94a.tar.gz
rust-174e73a3f6df6f96ab453493796e461164dea94a.zip
Auto merge of #119396 - Nadrieril:intersection-tracking, r=WaffleLapkin
Exhaustiveness: track overlapping ranges precisely

The `overlapping_range_endpoints` lint has false positives, e.g. https://github.com/rust-lang/rust/issues/117648. I expected that removing these false positives would have too much of a perf impact but never measured it. This PR is an experiment to see if the perf loss is manageable.

r? `@ghost`
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/lib.rs')
-rw-r--r--compiler/rustc_pattern_analysis/src/lib.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs
index b52643adcc9..374914055d8 100644
--- a/compiler/rustc_pattern_analysis/src/lib.rs
+++ b/compiler/rustc_pattern_analysis/src/lib.rs
@@ -124,8 +124,10 @@ pub fn analyze_match<'p, 'tcx>(
 
     let pat_column = PatternColumn::new(arms);
 
-    // Lint on ranges that overlap on their endpoints, which is likely a mistake.
-    lint_overlapping_range_endpoints(cx, &pat_column)?;
+    // Lint ranges that overlap on their endpoints, which is likely a mistake.
+    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.