Skip to content

Commit 61b532c

Browse files
committed
Release 0.6 with newer hashbrown and no mod raw
Fixes #21 so crate will work on Rust 1.82. We can't upgrade to `hashbrown 0.15` since it removes the `raw` table support. This is known upstream, and may just be something we have to live with: rust-lang/hashbrown#545 (comment) To align with `hashbrown`, and given this is a breaking change regardless, we remove the `raw` module just like `hashbrown` has. This should hopefully increase the chances that one day we can move to `hashbrown`'s new lower-level interface (`HashTable`) without a breaking change.
1 parent 46f1940 commit 61b532c

File tree

8 files changed

+68
-267
lines changed

8 files changed

+68
-267
lines changed

Cargo.toml

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "griddle"
3-
version = "0.5.2"
3+
version = "0.6.0"
44
authors = ["Jon Gjengset <[email protected]>"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"
@@ -14,9 +14,9 @@ categories = ["data-structures", "no-std"]
1414

1515
[dependencies]
1616
# For the default hasher
17-
ahash_ = { version = "0.7.0", default-features = false, optional = true, package = "ahash" }
17+
ahash_ = { version = "0.8.0", default-features = false, optional = true, package = "ahash" }
1818

19-
hashbrown = { version = "0.11.2", default-features = false, features = ["raw"] }
19+
hashbrown = { version = "0.14.0", default-features = false, features = ["raw"] }
2020

2121
# For external trait impls
2222
rayon_ = { version = "1.0", optional = true, package = "rayon" }
@@ -37,16 +37,20 @@ ahash-compile-time-rng = ["ahash_/compile-time-rng"]
3737
ahash = [ "ahash_", "hashbrown/ahash" ]
3838
serde = [ "serde_", "hashbrown/serde" ]
3939
rayon = [ "rayon_", "hashbrown/rayon" ]
40-
raw = []
4140

4241
# Enables usage of `#[inline]` on far more functions than by default in this
4342
# crate. This may lead to a performance increase but often comes at a compile
4443
# time cost.
4544
inline-more = [ "hashbrown/inline-more" ]
4645

46+
nightly = []
47+
4748
[package.metadata.docs.rs]
48-
features = ["rayon", "serde", "raw"]
49+
features = ["rayon", "serde"]
4950

5051
[[bench]]
5152
name = "vroom"
5253
harness = false
54+
55+
[lints.rust]
56+
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(tarpaulin)'] }

src/external_trait_impls/rayon/map.rs

-43
Original file line numberDiff line numberDiff line change
@@ -328,55 +328,12 @@ where
328328
#[cfg(test)]
329329
mod test_par_map {
330330
use alloc::vec::Vec;
331-
use core::hash::{Hash, Hasher};
332331
use core::sync::atomic::{AtomicUsize, Ordering};
333332

334333
use rayon_::prelude::*;
335334

336335
use crate::hash_map::HashMap;
337336

338-
struct Dropable<'a> {
339-
k: usize,
340-
counter: &'a AtomicUsize,
341-
}
342-
343-
impl Dropable<'_> {
344-
fn new(k: usize, counter: &AtomicUsize) -> Dropable<'_> {
345-
counter.fetch_add(1, Ordering::Relaxed);
346-
347-
Dropable { k, counter }
348-
}
349-
}
350-
351-
impl Drop for Dropable<'_> {
352-
fn drop(&mut self) {
353-
self.counter.fetch_sub(1, Ordering::Relaxed);
354-
}
355-
}
356-
357-
impl Clone for Dropable<'_> {
358-
fn clone(&self) -> Self {
359-
Dropable::new(self.k, self.counter)
360-
}
361-
}
362-
363-
impl Hash for Dropable<'_> {
364-
fn hash<H>(&self, state: &mut H)
365-
where
366-
H: Hasher,
367-
{
368-
self.k.hash(state)
369-
}
370-
}
371-
372-
impl PartialEq for Dropable<'_> {
373-
fn eq(&self, other: &Self) -> bool {
374-
self.k == other.k
375-
}
376-
}
377-
378-
impl Eq for Dropable<'_> {}
379-
380337
#[test]
381338
fn test_empty_iter() {
382339
let mut m: HashMap<isize, bool> = HashMap::new();

src/external_trait_impls/rayon/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
mod helpers;
22
pub(crate) mod map;
3-
pub(crate) mod raw;
43
pub(crate) mod set;

src/external_trait_impls/rayon/raw.rs

-59
This file was deleted.

src/lib.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#![cfg_attr(test, warn(rustdoc::all))]
5959
// hashbrown does this to avoid LLVM IR bloat in a few places.
6060
#![allow(clippy::manual_map)]
61+
#![cfg_attr(feature = "nightly", feature(extend_one))]
6162

6263
#[cfg(test)]
6364
#[macro_use]
@@ -66,26 +67,6 @@ extern crate std;
6667
#[cfg_attr(test, macro_use)]
6768
extern crate alloc;
6869

69-
#[cfg(feature = "raw")]
70-
/// Experimental and unsafe `RawTable` API. This module is only available if the
71-
/// `raw` feature is enabled.
72-
pub mod raw {
73-
#[path = "mod.rs"]
74-
mod inner;
75-
pub use inner::*;
76-
77-
#[cfg(feature = "rayon")]
78-
/// [rayon]-based parallel iterator types for raw hash tables.
79-
/// You will rarely need to interact with it directly unless you have need
80-
/// to name one of the iterator types.
81-
///
82-
/// [rayon]: https://docs.rs/rayon/1.0/rayon
83-
pub mod rayon {
84-
pub use crate::external_trait_impls::rayon::raw::*;
85-
}
86-
}
87-
#[cfg(not(feature = "raw"))]
88-
#[allow(dead_code)]
8970
mod raw;
9071

9172
mod external_trait_impls;

src/map.rs

+4-29
Original file line numberDiff line numberDiff line change
@@ -3171,7 +3171,6 @@ mod test_map {
31713171
use super::DefaultHashBuilder;
31723172
use super::Entry::{Occupied, Vacant};
31733173
use super::{HashMap, RawEntryMut};
3174-
use crate::TryReserveError::*;
31753174
use rand::{rngs::SmallRng, Rng, SeedableRng};
31763175
use std::cell::RefCell;
31773176
use std::usize;
@@ -4327,11 +4326,11 @@ mod test_map {
43274326
let key = "hello there";
43284327
let value = "value goes here";
43294328
assert!(a.is_empty());
4330-
a.insert(key.clone(), value.clone());
4329+
a.insert(key, value);
43314330
assert_eq!(a.len(), 1);
43324331
assert_eq!(a[key], value);
43334332

4334-
match a.entry(key.clone()) {
4333+
match a.entry(key) {
43354334
Vacant(_) => panic!(),
43364335
Occupied(e) => assert_eq!(key, *e.key()),
43374336
}
@@ -4346,11 +4345,11 @@ mod test_map {
43464345
let value = "value goes here";
43474346

43484347
assert!(a.is_empty());
4349-
match a.entry(key.clone()) {
4348+
match a.entry(key) {
43504349
Occupied(_) => panic!(),
43514350
Vacant(e) => {
43524351
assert_eq!(key, *e.key());
4353-
e.insert(value.clone());
4352+
e.insert(value);
43544353
}
43554354
}
43564355
assert_eq!(a.len(), 1);
@@ -4446,30 +4445,6 @@ mod test_map {
44464445
}
44474446
}
44484447

4449-
#[test]
4450-
#[cfg_attr(miri, ignore)] // FIXME: no OOM signalling (https://github.com/rust-lang/miri/issues/613)
4451-
fn test_try_reserve() {
4452-
let mut empty_bytes: HashMap<u8, u8> = HashMap::new();
4453-
4454-
const MAX_USIZE: usize = usize::MAX;
4455-
4456-
if let Err(CapacityOverflow) = empty_bytes.try_reserve(MAX_USIZE) {
4457-
} else {
4458-
panic!("usize::MAX should trigger an overflow!");
4459-
}
4460-
4461-
if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_USIZE / 8) {
4462-
} else {
4463-
// This may succeed if there is enough free memory. Attempt to
4464-
// allocate a second hashmap to ensure the allocation will fail.
4465-
let mut empty_bytes2: HashMap<u8, u8> = HashMap::new();
4466-
if let Err(AllocError { .. }) = empty_bytes2.try_reserve(MAX_USIZE / 8) {
4467-
} else {
4468-
panic!("usize::MAX / 8 should trigger an OOM!");
4469-
}
4470-
}
4471-
}
4472-
44734448
#[test]
44744449
#[cfg(feature = "raw")]
44754450
fn test_into_iter_refresh() {

0 commit comments

Comments
 (0)