diff options
Diffstat (limited to 'vendor/hashbrown/src')
-rw-r--r-- | vendor/hashbrown/src/map.rs | 2 | ||||
-rw-r--r-- | vendor/hashbrown/src/raw/mod.rs | 18 | ||||
-rw-r--r-- | vendor/hashbrown/src/set.rs | 2 |
3 files changed, 18 insertions, 4 deletions
diff --git a/vendor/hashbrown/src/map.rs b/vendor/hashbrown/src/map.rs index 5049aa2b5..e238bf66b 100644 --- a/vendor/hashbrown/src/map.rs +++ b/vendor/hashbrown/src/map.rs @@ -7679,7 +7679,7 @@ mod test_map { let vec: Vec<_> = (100..200).map(|i| (i, i)).collect(); a.extend(iter); a.extend(&vec); - a.extend(&create_arr::<i32, 100>(200, 1)); + a.extend(create_arr::<i32, 100>(200, 1)); assert_eq!(a.len(), 300); diff --git a/vendor/hashbrown/src/raw/mod.rs b/vendor/hashbrown/src/raw/mod.rs index 625ca1d71..0e96306ef 100644 --- a/vendor/hashbrown/src/raw/mod.rs +++ b/vendor/hashbrown/src/raw/mod.rs @@ -531,7 +531,7 @@ impl<T, A: Allocator + Clone> RawTable<T, A> { #[inline] #[cfg(feature = "raw")] pub fn allocation_info(&self) -> (NonNull<u8>, Layout) { - self.table.allocation_info(Self::TABLE_LAYOUT) + self.table.allocation_info_or_zero(Self::TABLE_LAYOUT) } /// Returns the index of a bucket from a `Bucket`. @@ -1189,7 +1189,7 @@ impl<A: Allocator + Clone> RawTableInner<A> { /// Searches for an element in the table. This uses dynamic dispatch to reduce the amount of /// code generated, but it is eliminated by LLVM optimizations. - #[inline] + #[inline(always)] fn find_inner(&self, hash: u64, eq: &mut dyn FnMut(usize) -> bool) -> Option<usize> { let h2_hash = h2(hash); let mut probe_seq = self.probe_seq(hash); @@ -1589,6 +1589,11 @@ impl<A: Allocator + Clone> RawTableInner<A> { #[inline] fn allocation_info(&self, table_layout: TableLayout) -> (NonNull<u8>, Layout) { + debug_assert!( + !self.is_empty_singleton(), + "this function can only be called on non-empty tables" + ); + // Avoid `Option::unwrap_or_else` because it bloats LLVM IR. let (layout, ctrl_offset) = match table_layout.calculate_layout_for(self.buckets()) { Some(lco) => lco, @@ -1600,6 +1605,15 @@ impl<A: Allocator + Clone> RawTableInner<A> { ) } + #[cfg(feature = "raw")] + fn allocation_info_or_zero(&self, table_layout: TableLayout) -> (NonNull<u8>, Layout) { + if self.is_empty_singleton() { + (NonNull::dangling(), Layout::new::<()>()) + } else { + self.allocation_info(table_layout) + } + } + /// Marks all table buckets as empty without dropping their contents. #[inline] fn clear_no_drop(&mut self) { diff --git a/vendor/hashbrown/src/set.rs b/vendor/hashbrown/src/set.rs index 60c1b1cd1..a8f24de80 100644 --- a/vendor/hashbrown/src/set.rs +++ b/vendor/hashbrown/src/set.rs @@ -2794,7 +2794,7 @@ mod test_set { let mut a = HashSet::new(); a.insert(1); - a.extend(&[2, 3, 4]); + a.extend([2, 3, 4]); assert_eq!(a.len(), 4); assert!(a.contains(&1)); |