Skip to content

Commit 448c4a4

Browse files
committed
Remove the unused overlapping_range_endpoints Vec
1 parent 8b66f49 commit 448c4a4

File tree

2 files changed

+5
-39
lines changed

2 files changed

+5
-39
lines changed

compiler/rustc_pattern_analysis/src/rustc.rs

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ pub type DeconstructedPat<'p, 'tcx> =
3232
crate::pat::DeconstructedPat<'p, RustcMatchCheckCtxt<'p, 'tcx>>;
3333
pub type MatchArm<'p, 'tcx> = crate::MatchArm<'p, RustcMatchCheckCtxt<'p, 'tcx>>;
3434
pub type MatchCtxt<'a, 'p, 'tcx> = crate::MatchCtxt<'a, RustcMatchCheckCtxt<'p, 'tcx>>;
35-
pub type OverlappingRanges<'p, 'tcx> =
36-
crate::usefulness::OverlappingRanges<'p, RustcMatchCheckCtxt<'p, 'tcx>>;
3735
pub(crate) type PlaceCtxt<'a, 'p, 'tcx> =
3836
crate::usefulness::PlaceCtxt<'a, RustcMatchCheckCtxt<'p, 'tcx>>;
3937
pub(crate) type SplitConstructorSet<'p, 'tcx> =

compiler/rustc_pattern_analysis/src/usefulness.rs

+5-37
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,6 @@ fn collect_overlapping_range_endpoints<'p, Cx: TypeCx>(
13441344
overlap_range: IntRange,
13451345
matrix: &Matrix<'p, Cx>,
13461346
specialized_matrix: &Matrix<'p, Cx>,
1347-
_overlapping_range_endpoints: &mut Vec<OverlappingRanges<'p, Cx>>,
13481347
) {
13491348
let overlap = overlap_range.lo;
13501349
// Ranges that look like `lo..=overlap`.
@@ -1416,7 +1415,6 @@ fn collect_overlapping_range_endpoints<'p, Cx: TypeCx>(
14161415
fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
14171416
mcx: MatchCtxt<'a, Cx>,
14181417
matrix: &mut Matrix<'p, Cx>,
1419-
overlapping_range_endpoints: &mut Vec<OverlappingRanges<'p, Cx>>,
14201418
is_top_level: bool,
14211419
) -> Result<WitnessMatrix<Cx>, Cx::Error> {
14221420
debug_assert!(matrix.rows().all(|r| r.len() == matrix.column_count()));
@@ -1496,12 +1494,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
14961494
let ctor_is_relevant = matches!(ctor, Constructor::Missing) || missing_ctors.is_empty();
14971495
let mut spec_matrix = matrix.specialize_constructor(pcx, &ctor, ctor_is_relevant);
14981496
let mut witnesses = ensure_sufficient_stack(|| {
1499-
compute_exhaustiveness_and_usefulness(
1500-
mcx,
1501-
&mut spec_matrix,
1502-
overlapping_range_endpoints,
1503-
false,
1504-
)
1497+
compute_exhaustiveness_and_usefulness(mcx, &mut spec_matrix, false)
15051498
})?;
15061499

15071500
// Transform witnesses for `spec_matrix` into witnesses for `matrix`.
@@ -1530,13 +1523,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
15301523
&& spec_matrix.rows.len() >= 2
15311524
&& spec_matrix.rows.iter().any(|row| !row.intersects.is_empty())
15321525
{
1533-
collect_overlapping_range_endpoints(
1534-
mcx,
1535-
overlap_range,
1536-
matrix,
1537-
&spec_matrix,
1538-
overlapping_range_endpoints,
1539-
);
1526+
collect_overlapping_range_endpoints(mcx, overlap_range, matrix, &spec_matrix);
15401527
}
15411528
}
15421529
}
@@ -1563,23 +1550,13 @@ pub enum Usefulness<'p, Cx: TypeCx> {
15631550
Redundant,
15641551
}
15651552

1566-
/// Indicates that the range `pat` overlapped with all the ranges in `overlaps_with`, where the
1567-
/// range they overlapped over is `overlaps_on`. We only detect singleton overlaps.
1568-
#[derive(Clone, Debug)]
1569-
pub struct OverlappingRanges<'p, Cx: TypeCx> {
1570-
pub pat: &'p DeconstructedPat<'p, Cx>,
1571-
pub overlaps_on: IntRange,
1572-
pub overlaps_with: Vec<&'p DeconstructedPat<'p, Cx>>,
1573-
}
1574-
15751553
/// The output of checking a match for exhaustiveness and arm usefulness.
15761554
pub struct UsefulnessReport<'p, Cx: TypeCx> {
15771555
/// For each arm of the input, whether that arm is useful after the arms above it.
15781556
pub arm_usefulness: Vec<(MatchArm<'p, Cx>, Usefulness<'p, Cx>)>,
15791557
/// If the match is exhaustive, this is empty. If not, this contains witnesses for the lack of
15801558
/// exhaustiveness.
15811559
pub non_exhaustiveness_witnesses: Vec<WitnessPat<Cx>>,
1582-
pub overlapping_range_endpoints: Vec<OverlappingRanges<'p, Cx>>,
15831560
}
15841561

15851562
/// Computes whether a match is exhaustive and which of its arms are useful.
@@ -1590,14 +1567,9 @@ pub fn compute_match_usefulness<'p, Cx: TypeCx>(
15901567
scrut_ty: Cx::Ty,
15911568
scrut_validity: ValidityConstraint,
15921569
) -> Result<UsefulnessReport<'p, Cx>, Cx::Error> {
1593-
let mut overlapping_range_endpoints = Vec::new();
15941570
let mut matrix = Matrix::new(arms, scrut_ty, scrut_validity);
1595-
let non_exhaustiveness_witnesses = compute_exhaustiveness_and_usefulness(
1596-
cx,
1597-
&mut matrix,
1598-
&mut overlapping_range_endpoints,
1599-
true,
1600-
)?;
1571+
let non_exhaustiveness_witnesses =
1572+
compute_exhaustiveness_and_usefulness(cx, &mut matrix, true)?;
16011573

16021574
let non_exhaustiveness_witnesses: Vec<_> = non_exhaustiveness_witnesses.single_column();
16031575
let arm_usefulness: Vec<_> = arms
@@ -1615,9 +1587,5 @@ pub fn compute_match_usefulness<'p, Cx: TypeCx>(
16151587
})
16161588
.collect();
16171589

1618-
Ok(UsefulnessReport {
1619-
arm_usefulness,
1620-
non_exhaustiveness_witnesses,
1621-
overlapping_range_endpoints,
1622-
})
1590+
Ok(UsefulnessReport { arm_usefulness, non_exhaustiveness_witnesses })
16231591
}

0 commit comments

Comments
 (0)