Auto merge of #49108 - SimonSapin:sip, r=TimNN
Remove or hide deprecated unstable SipHasher{13,24}
Deprecated since Rust 1.13.0.
This commit is contained in:
@@ -99,9 +99,10 @@ use mem;
|
|||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
pub use self::sip::SipHasher;
|
pub use self::sip::SipHasher;
|
||||||
|
|
||||||
#[unstable(feature = "sip_hash_13", issue = "34767")]
|
#[unstable(feature = "hashmap_internals", issue = "0")]
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
pub use self::sip::{SipHasher13, SipHasher24};
|
#[doc(hidden)]
|
||||||
|
pub use self::sip::SipHasher13;
|
||||||
|
|
||||||
mod sip;
|
mod sip;
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,11 @@ use mem;
|
|||||||
/// (eg. `collections::HashMap` uses it by default).
|
/// (eg. `collections::HashMap` uses it by default).
|
||||||
///
|
///
|
||||||
/// See: <https://131002.net/siphash>
|
/// See: <https://131002.net/siphash>
|
||||||
#[unstable(feature = "sip_hash_13", issue = "34767")]
|
#[unstable(feature = "hashmap_internals", issue = "0")]
|
||||||
#[rustc_deprecated(since = "1.13.0",
|
#[rustc_deprecated(since = "1.13.0",
|
||||||
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
#[doc(hidden)]
|
||||||
pub struct SipHasher13 {
|
pub struct SipHasher13 {
|
||||||
hasher: Hasher<Sip13Rounds>,
|
hasher: Hasher<Sip13Rounds>,
|
||||||
}
|
}
|
||||||
@@ -34,11 +35,11 @@ pub struct SipHasher13 {
|
|||||||
/// An implementation of SipHash 2-4.
|
/// An implementation of SipHash 2-4.
|
||||||
///
|
///
|
||||||
/// See: <https://131002.net/siphash/>
|
/// See: <https://131002.net/siphash/>
|
||||||
#[unstable(feature = "sip_hash_13", issue = "34767")]
|
#[unstable(feature = "hashmap_internals", issue = "0")]
|
||||||
#[rustc_deprecated(since = "1.13.0",
|
#[rustc_deprecated(since = "1.13.0",
|
||||||
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct SipHasher24 {
|
struct SipHasher24 {
|
||||||
hasher: Hasher<Sip24Rounds>,
|
hasher: Hasher<Sip24Rounds>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,14 +157,16 @@ impl SipHasher {
|
|||||||
#[rustc_deprecated(since = "1.13.0",
|
#[rustc_deprecated(since = "1.13.0",
|
||||||
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
||||||
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher {
|
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher {
|
||||||
SipHasher(SipHasher24::new_with_keys(key0, key1))
|
SipHasher(SipHasher24 {
|
||||||
|
hasher: Hasher::new_with_keys(key0, key1)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SipHasher13 {
|
impl SipHasher13 {
|
||||||
/// Creates a new `SipHasher13` with the two initial keys set to 0.
|
/// Creates a new `SipHasher13` with the two initial keys set to 0.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "sip_hash_13", issue = "34767")]
|
#[unstable(feature = "hashmap_internals", issue = "0")]
|
||||||
#[rustc_deprecated(since = "1.13.0",
|
#[rustc_deprecated(since = "1.13.0",
|
||||||
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
||||||
pub fn new() -> SipHasher13 {
|
pub fn new() -> SipHasher13 {
|
||||||
@@ -172,7 +175,7 @@ impl SipHasher13 {
|
|||||||
|
|
||||||
/// Creates a `SipHasher13` that is keyed off the provided keys.
|
/// Creates a `SipHasher13` that is keyed off the provided keys.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "sip_hash_13", issue = "34767")]
|
#[unstable(feature = "hashmap_internals", issue = "0")]
|
||||||
#[rustc_deprecated(since = "1.13.0",
|
#[rustc_deprecated(since = "1.13.0",
|
||||||
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
||||||
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher13 {
|
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher13 {
|
||||||
@@ -182,28 +185,6 @@ impl SipHasher13 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SipHasher24 {
|
|
||||||
/// Creates a new `SipHasher24` with the two initial keys set to 0.
|
|
||||||
#[inline]
|
|
||||||
#[unstable(feature = "sip_hash_13", issue = "34767")]
|
|
||||||
#[rustc_deprecated(since = "1.13.0",
|
|
||||||
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
|
||||||
pub fn new() -> SipHasher24 {
|
|
||||||
SipHasher24::new_with_keys(0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a `SipHasher24` that is keyed off the provided keys.
|
|
||||||
#[inline]
|
|
||||||
#[unstable(feature = "sip_hash_13", issue = "34767")]
|
|
||||||
#[rustc_deprecated(since = "1.13.0",
|
|
||||||
reason = "use `std::collections::hash_map::DefaultHasher` instead")]
|
|
||||||
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher24 {
|
|
||||||
SipHasher24 {
|
|
||||||
hasher: Hasher::new_with_keys(key0, key1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: Sip> Hasher<S> {
|
impl<S: Sip> Hasher<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn new_with_keys(key0: u64, key1: u64) -> Hasher<S> {
|
fn new_with_keys(key0: u64, key1: u64) -> Hasher<S> {
|
||||||
@@ -271,16 +252,16 @@ impl<S: Sip> Hasher<S> {
|
|||||||
impl super::Hasher for SipHasher {
|
impl super::Hasher for SipHasher {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write(&mut self, msg: &[u8]) {
|
fn write(&mut self, msg: &[u8]) {
|
||||||
self.0.write(msg)
|
self.0.hasher.write(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn finish(&self) -> u64 {
|
fn finish(&self) -> u64 {
|
||||||
self.0.finish()
|
self.0.hasher.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "sip_hash_13", issue = "34767")]
|
#[unstable(feature = "hashmap_internals", issue = "0")]
|
||||||
impl super::Hasher for SipHasher13 {
|
impl super::Hasher for SipHasher13 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write(&mut self, msg: &[u8]) {
|
fn write(&mut self, msg: &[u8]) {
|
||||||
@@ -293,19 +274,6 @@ impl super::Hasher for SipHasher13 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "sip_hash_13", issue = "34767")]
|
|
||||||
impl super::Hasher for SipHasher24 {
|
|
||||||
#[inline]
|
|
||||||
fn write(&mut self, msg: &[u8]) {
|
|
||||||
self.hasher.write(msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn finish(&self) -> u64 {
|
|
||||||
self.hasher.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: Sip> super::Hasher for Hasher<S> {
|
impl<S: Sip> super::Hasher for Hasher<S> {
|
||||||
// see short_write comment for explanation
|
// see short_write comment for explanation
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#![allow(deprecated)]
|
#![allow(deprecated)]
|
||||||
|
|
||||||
use core::hash::{Hash, Hasher};
|
use core::hash::{Hash, Hasher};
|
||||||
use core::hash::{SipHasher, SipHasher13, SipHasher24};
|
use core::hash::{SipHasher, SipHasher13};
|
||||||
use core::{slice, mem};
|
use core::{slice, mem};
|
||||||
|
|
||||||
// Hash just the bytes of the slice, without length prefix
|
// Hash just the bytes of the slice, without length prefix
|
||||||
@@ -224,14 +224,14 @@ fn test_siphash_2_4() {
|
|||||||
let k1 = 0x_0f_0e_0d_0c_0b_0a_09_08;
|
let k1 = 0x_0f_0e_0d_0c_0b_0a_09_08;
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let mut t = 0;
|
let mut t = 0;
|
||||||
let mut state_inc = SipHasher24::new_with_keys(k0, k1);
|
let mut state_inc = SipHasher::new_with_keys(k0, k1);
|
||||||
|
|
||||||
while t < 64 {
|
while t < 64 {
|
||||||
let vec = u8to64_le!(vecs[t], 0);
|
let vec = u8to64_le!(vecs[t], 0);
|
||||||
let out = hash_with(SipHasher24::new_with_keys(k0, k1), &Bytes(&buf));
|
let out = hash_with(SipHasher::new_with_keys(k0, k1), &Bytes(&buf));
|
||||||
assert_eq!(vec, out);
|
assert_eq!(vec, out);
|
||||||
|
|
||||||
let full = hash_with(SipHasher24::new_with_keys(k0, k1), &Bytes(&buf));
|
let full = hash_with(SipHasher::new_with_keys(k0, k1), &Bytes(&buf));
|
||||||
let i = state_inc.finish();
|
let i = state_inc.finish();
|
||||||
|
|
||||||
assert_eq!(full, i);
|
assert_eq!(full, i);
|
||||||
@@ -322,13 +322,13 @@ fn test_hash_no_concat_alias() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_write_short_works() {
|
fn test_write_short_works() {
|
||||||
let test_usize = 0xd0c0b0a0usize;
|
let test_usize = 0xd0c0b0a0usize;
|
||||||
let mut h1 = SipHasher24::new();
|
let mut h1 = SipHasher::new();
|
||||||
h1.write_usize(test_usize);
|
h1.write_usize(test_usize);
|
||||||
h1.write(b"bytes");
|
h1.write(b"bytes");
|
||||||
h1.write(b"string");
|
h1.write(b"string");
|
||||||
h1.write_u8(0xFFu8);
|
h1.write_u8(0xFFu8);
|
||||||
h1.write_u8(0x01u8);
|
h1.write_u8(0x01u8);
|
||||||
let mut h2 = SipHasher24::new();
|
let mut h2 = SipHasher::new();
|
||||||
h2.write(unsafe {
|
h2.write(unsafe {
|
||||||
slice::from_raw_parts(&test_usize as *const _ as *const u8,
|
slice::from_raw_parts(&test_usize as *const _ as *const u8,
|
||||||
mem::size_of::<usize>())
|
mem::size_of::<usize>())
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#![feature(fixed_size_array)]
|
#![feature(fixed_size_array)]
|
||||||
#![feature(flt2dec)]
|
#![feature(flt2dec)]
|
||||||
#![feature(fmt_internals)]
|
#![feature(fmt_internals)]
|
||||||
|
#![feature(hashmap_internals)]
|
||||||
#![feature(iterator_step_by)]
|
#![feature(iterator_step_by)]
|
||||||
#![feature(i128_type)]
|
#![feature(i128_type)]
|
||||||
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
|
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
|
||||||
@@ -35,7 +36,6 @@
|
|||||||
#![feature(range_is_empty)]
|
#![feature(range_is_empty)]
|
||||||
#![feature(raw)]
|
#![feature(raw)]
|
||||||
#![feature(refcell_replace_swap)]
|
#![feature(refcell_replace_swap)]
|
||||||
#![feature(sip_hash_13)]
|
|
||||||
#![feature(slice_patterns)]
|
#![feature(slice_patterns)]
|
||||||
#![feature(sort_internals)]
|
#![feature(sort_internals)]
|
||||||
#![feature(specialization)]
|
#![feature(specialization)]
|
||||||
|
|||||||
@@ -267,7 +267,7 @@
|
|||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
#![feature(fnbox)]
|
#![feature(fnbox)]
|
||||||
#![feature(generic_param_attrs)]
|
#![feature(generic_param_attrs)]
|
||||||
#![feature(hashmap_hasher)]
|
#![feature(hashmap_internals)]
|
||||||
#![feature(heap_api)]
|
#![feature(heap_api)]
|
||||||
#![feature(i128)]
|
#![feature(i128)]
|
||||||
#![feature(i128_type)]
|
#![feature(i128_type)]
|
||||||
@@ -298,7 +298,6 @@
|
|||||||
#![feature(raw)]
|
#![feature(raw)]
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
#![feature(stdsimd)]
|
#![feature(stdsimd)]
|
||||||
#![feature(sip_hash_13)]
|
|
||||||
#![feature(slice_bytes)]
|
#![feature(slice_bytes)]
|
||||||
#![feature(slice_concat_ext)]
|
#![feature(slice_concat_ext)]
|
||||||
#![feature(slice_internals)]
|
#![feature(slice_internals)]
|
||||||
|
|||||||
Reference in New Issue
Block a user