From 6cf3786ba48198a54f447274d4928e538b9159bd Mon Sep 17 00:00:00 2001 From: Will Crichton Date: Tue, 24 Aug 2021 18:14:39 -0700 Subject: [PATCH] Fix HybridBitSet port issue --- compiler/rustc_index/src/bit_set.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index 0b5745072ad..bfe2082e756 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -247,10 +247,13 @@ impl BitRelations> for BitSet { } } -fn sequential_update(mut f: impl FnMut(T) -> bool, it: impl Iterator) -> bool { +fn sequential_update( + mut self_update: impl FnMut(T) -> bool, + it: impl Iterator, +) -> bool { let mut changed = false; for elem in it { - changed |= f(elem); + changed |= self_update(elem); } changed } @@ -342,7 +345,17 @@ impl BitRelations> for HybridBitSet { match self { HybridBitSet::Sparse(self_sparse) => { match other { - HybridBitSet::Sparse(other_sparse) => self_sparse.union(other_sparse), + HybridBitSet::Sparse(other_sparse) => { + // Both sets are sparse. Add the elements in + // `other_sparse` to `self` one at a time. This + // may or may not cause `self` to be densified. + assert_eq!(self.domain_size(), other.domain_size()); + let mut changed = false; + for elem in other_sparse.iter() { + changed |= self.insert(*elem); + } + changed + } HybridBitSet::Dense(other_dense) => { // `self` is sparse and `other` is dense. To