summaryrefslogtreecommitdiffstats
path: root/vendor/hashbrown/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/hashbrown/src
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/hashbrown/src')
-rw-r--r--vendor/hashbrown/src/map.rs2
-rw-r--r--vendor/hashbrown/src/raw/mod.rs18
-rw-r--r--vendor/hashbrown/src/set.rs2
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));