From 86bd551e4c8954330e5e0d71c09c4ecbf514a5b6 Mon Sep 17 00:00:00 2001 From: Will Crichton Date: Fri, 27 Aug 2021 11:17:27 -0700 Subject: [PATCH] Addd missing domain size assertions --- compiler/rustc_index/src/bit_set.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index fad3b95cf43a9..8903ed9d9e2af 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -289,6 +289,7 @@ fn dense_sparse_intersect( // hybrid REL dense impl BitRelations> for HybridBitSet { fn union(&mut self, other: &BitSet) -> bool { + assert_eq!(self.domain_size(), other.domain_size); match self { HybridBitSet::Sparse(sparse) => { // `self` is sparse and `other` is dense. To @@ -316,6 +317,7 @@ impl BitRelations> for HybridBitSet { } fn subtract(&mut self, other: &BitSet) -> bool { + assert_eq!(self.domain_size(), other.domain_size); match self { HybridBitSet::Sparse(sparse) => { sequential_update(|elem| sparse.remove(elem), other.iter()) @@ -325,6 +327,7 @@ impl BitRelations> for HybridBitSet { } fn intersect(&mut self, other: &BitSet) -> bool { + assert_eq!(self.domain_size(), other.domain_size); match self { HybridBitSet::Sparse(sparse) => sparse_intersect(sparse, |elem| other.contains(*elem)), HybridBitSet::Dense(dense) => dense.intersect(other), @@ -385,7 +388,6 @@ impl BitRelations> for HybridBitSet { // 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);