rustc_pattern_analysis::usefulness

Function collect_overlapping_range_endpoints

source
fn collect_overlapping_range_endpoints<'p, Cx: PatCx>(
    cx: &Cx,
    overlap_range: IntRange,
    matrix: &Matrix<'p, Cx>,
    specialized_matrix: &Matrix<'p, Cx>,
)
Expand description

Collect ranges that overlap like lo..=overlap/overlap..=hi. Must be called during exhaustiveness checking, if we find a singleton range after constructor splitting. This reuses row intersection information to only detect ranges that truly overlap.

If two ranges overlapped, the split set will contain their intersection as a singleton. Specialization will then select rows that match the overlap, and exhaustiveness will compute which rows have an intersection that includes the overlap. That gives us all the info we need to compute overlapping ranges without false positives.

We can however get false negatives because exhaustiveness does not explore all cases. See the section on relevancy at the top of the file.