Skip to content

Commit 50eca1a

Browse files
committed
Stabilize BuildHasher::hash_one in Rust 1.71
1 parent 7dbeb5b commit 50eca1a

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use std::env;
44

55
fn main() {
66
println!("cargo:rerun-if-changed=build.rs");
7+
if let Some(true) = version_check::is_min_version("1.71.0") {
8+
println!("cargo:rustc-cfg=build_hasher_hash_one");
9+
}
710
if let Some(true) = version_check::supports_feature("specialize") {
811
println!("cargo:rustc-cfg=feature=\"specialize\"");
912
}

src/random_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl BuildHasher for RandomState {
453453
/// implementation of [`Hash`]. The way to create a combined hash of
454454
/// multiple values is to call [`Hash::hash`] multiple times using the same
455455
/// [`Hasher`], not to call this method repeatedly and combine the results.
456-
#[cfg(feature = "specialize")]
456+
#[cfg(build_hasher_hash_one)]
457457
#[inline]
458458
fn hash_one<T: Hash>(&self, x: T) -> u64 {
459459
RandomState::hash_one(self, x)

tests/bench.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(feature = "specialize", feature(build_hasher_simple_hash_one))]
2-
31
use ahash::{AHasher, RandomState};
42
use criterion::*;
53
use fxhash::FxHasher;

tests/map_tests.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(feature = "specialize", feature(build_hasher_simple_hash_one))]
2-
31
use std::hash::{BuildHasher, Hash, Hasher};
42

53
use ahash::RandomState;
@@ -151,13 +149,13 @@ fn check_for_collisions<H: Hash, B: BuildHasher>(build_hasher: &B, items: &[H],
151149
);
152150
}
153151

154-
#[cfg(feature = "specialize")]
152+
#[cfg(build_hasher_hash_one)]
155153
#[allow(unused)] // False positive
156154
fn hash<H: Hash, B: BuildHasher>(b: &H, build_hasher: &B) -> u64 {
157155
build_hasher.hash_one(b)
158156
}
159157

160-
#[cfg(not(feature = "specialize"))]
158+
#[cfg(not(build_hasher_hash_one))]
161159
#[allow(unused)] // False positive
162160
fn hash<H: Hash, B: BuildHasher>(b: &H, build_hasher: &B) -> u64 {
163161
let mut hasher = build_hasher.build_hasher();

0 commit comments

Comments
 (0)