Skip to content

Commit

Permalink
Require Ord for rustc_index::SparseBitSet::last_set_in
Browse files Browse the repository at this point in the history
  • Loading branch information
pierwill committed Dec 22, 2021
1 parent 8df9248 commit a4a8c24
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ impl<T: Idx> SparseBitSet<T> {
self.elems.iter()
}

bit_relations_inherent_impls! {}
}

impl<T: Idx + Ord> SparseBitSet<T> {
fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T> {
let mut last_leq = None;
for e in self.iter() {
Expand All @@ -724,8 +728,6 @@ impl<T: Idx> SparseBitSet<T> {
}
last_leq
}

bit_relations_inherent_impls! {}
}

/// A fixed-size bitset type with a hybrid representation: sparse when there
Expand Down Expand Up @@ -802,7 +804,10 @@ impl<T: Idx> HybridBitSet<T> {
/// Returns the previous element present in the bitset from `elem`,
/// inclusively of elem. That is, will return `Some(elem)` if elem is in the
/// bitset.
pub fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T> {
pub fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T>
where
T: Ord,
{
match self {
HybridBitSet::Sparse(sparse) => sparse.last_set_in(range),
HybridBitSet::Dense(dense) => dense.last_set_in(range),
Expand Down

0 comments on commit a4a8c24

Please sign in to comment.