From 0e1502b269b4b4cbcf01275d0c64b592e19b0ce8 Mon Sep 17 00:00:00 2001 From: konstin Date: Tue, 5 Nov 2024 01:17:41 +0100 Subject: [PATCH] Filter to valid segments --- version-ranges/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/version-ranges/src/lib.rs b/version-ranges/src/lib.rs index 90c9e2d9..9d457e5d 100644 --- a/version-ranges/src/lib.rs +++ b/version-ranges/src/lib.rs @@ -865,7 +865,10 @@ impl Ranges { // 1. The segments are sorted, from lowest to highest (through `Ord`): By sorting. // 2. Each segment contains at least one version (start < end): By `union`. // 3. There is at least one version between two segments: By `union`. - let mut segments: SmallVec<_> = segments.into_iter().collect(); + let mut segments: SmallVec<_> = segments + .into_iter() + .filter(|segment| valid_segment(&segment.start_bound(), &segment.end_bound())) + .collect(); segments.sort_by(|a: &Interval, b: &Interval| { if a.start_bound() == b.start_bound() { // The ends don't matter, we merge them anyway.