Register new snapshots

This commit is contained in:
Alex Crichton
2015-02-19 18:35:52 -08:00
parent 522d09dfec
commit 6686f7aa47
41 changed files with 20 additions and 5242 deletions

View File

@@ -35,13 +35,6 @@ macro_rules! array_impls {
}
}
#[cfg(stage0)]
impl<S: hash::Writer + hash::Hasher, T: Hash<S>> Hash<S> for [T; $N] {
fn hash(&self, state: &mut S) {
Hash::hash(&self[..], state)
}
}
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Hash> Hash for [T; $N] {
fn hash<H: hash::Hasher>(&self, state: &mut H) {

View File

@@ -73,7 +73,6 @@ mod sip;
/// to compute the hash. Specific implementations of this trait may specialize
/// for particular instances of `H` in order to be able to optimize the hashing
/// behavior.
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Hash {
/// Feeds this value into the state given, updating the hasher as necessary.
@@ -89,72 +88,40 @@ pub trait Hash {
}
}
/// A hashable type.
///
/// The `H` type parameter is an abstract hash state that is used by the `Hash`
/// to compute the hash. Specific implementations of this trait may specialize
/// for particular instances of `H` in order to be able to optimize the hashing
/// behavior.
#[cfg(stage0)]
pub trait Hash<H: Hasher> {
/// Feeds this value into the state given, updating the hasher as necessary.
fn hash(&self, state: &mut H);
}
/// A trait which represents the ability to hash an arbitrary stream of bytes.
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Hasher {
/// Result type of one run of hashing generated by this hasher.
#[cfg(stage0)]
type Output;
/// Resets this hasher back to its initial state (as if it were just
/// created).
#[cfg(stage0)]
fn reset(&mut self);
/// Completes a round of hashing, producing the output hash generated.
#[cfg(stage0)]
fn finish(&self) -> Self::Output;
/// Completes a round of hashing, producing the output hash generated.
#[cfg(not(stage0))]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn finish(&self) -> u64;
/// Writes some data into this `Hasher`
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
fn write(&mut self, bytes: &[u8]);
/// Write a single `u8` into this hasher
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_u8(&mut self, i: u8) { self.write(&[i]) }
/// Write a single `u16` into this hasher.
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_u16(&mut self, i: u16) {
self.write(&unsafe { mem::transmute::<_, [u8; 2]>(i) })
}
/// Write a single `u32` into this hasher.
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_u32(&mut self, i: u32) {
self.write(&unsafe { mem::transmute::<_, [u8; 4]>(i) })
}
/// Write a single `u64` into this hasher.
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_u64(&mut self, i: u64) {
self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) })
}
/// Write a single `usize` into this hasher.
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_usize(&mut self, i: usize) {
@@ -166,58 +133,31 @@ pub trait Hasher {
}
/// Write a single `i8` into this hasher.
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_i8(&mut self, i: i8) { self.write_u8(i as u8) }
/// Write a single `i16` into this hasher.
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_i16(&mut self, i: i16) { self.write_u16(i as u16) }
/// Write a single `i32` into this hasher.
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_i32(&mut self, i: i32) { self.write_u32(i as u32) }
/// Write a single `i64` into this hasher.
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_i64(&mut self, i: i64) { self.write_u64(i as u64) }
/// Write a single `isize` into this hasher.
#[cfg(not(stage0))]
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
fn write_isize(&mut self, i: isize) { self.write_usize(i as usize) }
}
/// A common bound on the `Hasher` parameter to `Hash` implementations in order
/// to generically hash an aggregate.
#[unstable(feature = "hash",
reason = "this trait will likely be replaced by io::Writer")]
#[allow(missing_docs)]
#[cfg(stage0)]
pub trait Writer {
fn write(&mut self, bytes: &[u8]);
}
/// Hash a value with the default SipHasher algorithm (two initial keys of 0).
///
/// The specified value will be hashed with this hasher and then the resulting
/// hash will be returned.
#[cfg(stage0)]
pub fn hash<T: Hash<H>, H: Hasher + Default>(value: &T) -> H::Output {
let mut h: H = Default::default();
value.hash(&mut h);
h.finish()
}
/// Hash a value with the default SipHasher algorithm (two initial keys of 0).
///
/// The specified value will be hashed with this hasher and then the resulting
/// hash will be returned.
#[cfg(not(stage0))]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
pub fn hash<T: Hash, H: Hasher + Default>(value: &T) -> u64 {
let mut h: H = Default::default();
@@ -227,145 +167,6 @@ pub fn hash<T: Hash, H: Hasher + Default>(value: &T) -> u64 {
//////////////////////////////////////////////////////////////////////////////
#[cfg(stage0)]
mod impls {
use prelude::*;
use mem;
use num::Int;
use super::*;
macro_rules! impl_hash {
($ty:ident, $uty:ident) => {
impl<S: Writer + Hasher> Hash<S> for $ty {
#[inline]
fn hash(&self, state: &mut S) {
let a: [u8; ::$ty::BYTES] = unsafe {
mem::transmute(*self)
};
state.write(&a)
}
}
}
}
impl_hash! { u8, u8 }
impl_hash! { u16, u16 }
impl_hash! { u32, u32 }
impl_hash! { u64, u64 }
impl_hash! { uint, uint }
impl_hash! { i8, u8 }
impl_hash! { i16, u16 }
impl_hash! { i32, u32 }
impl_hash! { i64, u64 }
impl_hash! { int, uint }
impl<S: Writer + Hasher> Hash<S> for bool {
#[inline]
fn hash(&self, state: &mut S) {
(*self as u8).hash(state);
}
}
impl<S: Writer + Hasher> Hash<S> for char {
#[inline]
fn hash(&self, state: &mut S) {
(*self as u32).hash(state);
}
}
impl<S: Writer + Hasher> Hash<S> for str {
#[inline]
fn hash(&self, state: &mut S) {
state.write(self.as_bytes());
0xffu8.hash(state)
}
}
macro_rules! impl_hash_tuple {
() => (
impl<S: Hasher> Hash<S> for () {
#[inline]
fn hash(&self, _state: &mut S) {}
}
);
( $($name:ident)+) => (
impl<S: Hasher, $($name: Hash<S>),*> Hash<S> for ($($name,)*) {
#[inline]
#[allow(non_snake_case)]
fn hash(&self, state: &mut S) {
match *self {
($(ref $name,)*) => {
$(
$name.hash(state);
)*
}
}
}
}
);
}
impl_hash_tuple! {}
impl_hash_tuple! { A }
impl_hash_tuple! { A B }
impl_hash_tuple! { A B C }
impl_hash_tuple! { A B C D }
impl_hash_tuple! { A B C D E }
impl_hash_tuple! { A B C D E F }
impl_hash_tuple! { A B C D E F G }
impl_hash_tuple! { A B C D E F G H }
impl_hash_tuple! { A B C D E F G H I }
impl_hash_tuple! { A B C D E F G H I J }
impl_hash_tuple! { A B C D E F G H I J K }
impl_hash_tuple! { A B C D E F G H I J K L }
impl<S: Writer + Hasher, T: Hash<S>> Hash<S> for [T] {
#[inline]
fn hash(&self, state: &mut S) {
self.len().hash(state);
for elt in self {
elt.hash(state);
}
}
}
impl<'a, S: Hasher, T: ?Sized + Hash<S>> Hash<S> for &'a T {
#[inline]
fn hash(&self, state: &mut S) {
(**self).hash(state);
}
}
impl<'a, S: Hasher, T: ?Sized + Hash<S>> Hash<S> for &'a mut T {
#[inline]
fn hash(&self, state: &mut S) {
(**self).hash(state);
}
}
impl<S: Writer + Hasher, T> Hash<S> for *const T {
#[inline]
fn hash(&self, state: &mut S) {
// NB: raw-pointer Hash does _not_ dereference
// to the target; it just gives you the pointer-bytes.
(*self as uint).hash(state);
}
}
impl<S: Writer + Hasher, T> Hash<S> for *mut T {
#[inline]
fn hash(&self, state: &mut S) {
// NB: raw-pointer Hash does _not_ dereference
// to the target; it just gives you the pointer-bytes.
(*self as uint).hash(state);
}
}
}
#[cfg(not(stage0))]
mod impls {
use prelude::*;

View File

@@ -16,8 +16,6 @@ use prelude::*;
use default::Default;
use super::Hasher;
#[cfg(stage0)]
use super::Writer;
/// An implementation of SipHash 2-4.
///
@@ -175,26 +173,9 @@ impl SipHasher {
}
}
#[cfg(stage0)]
impl Writer for SipHasher {
#[inline]
fn write(&mut self, msg: &[u8]) {
self.write(msg)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Hasher for SipHasher {
#[cfg(stage0)]
type Output = u64;
#[cfg(stage0)]
fn reset(&mut self) {
self.reset();
}
#[inline]
#[cfg(not(stage0))]
fn write(&mut self, msg: &[u8]) {
self.write(msg)
}

View File

@@ -31,20 +31,10 @@ use option::Option;
use hash::Hash;
use hash::Hasher;
/// Types able to be transferred across thread boundaries.
#[unstable(feature = "core",
reason = "will be overhauled with new lifetime rules; see RFC 458")]
#[lang="send"]
#[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"]
#[cfg(stage0)]
pub unsafe trait Send: 'static {
// empty.
}
/// Types able to be transferred across thread boundaries.
#[stable(feature = "rust1", since = "1.0.0")]
#[lang="send"]
#[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"]
#[cfg(not(stage0))]
pub unsafe trait Send : MarkerTrait {
// empty.
}
@@ -233,13 +223,6 @@ pub struct Managed;
macro_rules! impls{
($t: ident) => (
#[cfg(stage0)]
impl<T:?Sized, S: Hasher> Hash<S> for $t<T> {
#[inline]
fn hash(&self, _: &mut S) {
}
}
#[cfg(not(stage0))]
impl<T:?Sized> Hash for $t<T> {
#[inline]
fn hash<H: Hasher>(&self, _: &mut H) {
@@ -348,14 +331,6 @@ impl<T:?Sized> MarkerTrait for T { }
#[stable(feature = "rust1", since = "1.0.0")]
pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
#[cfg(stage0)] // built into the trait matching system after stage0
impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { }
/// Specific to stage0. You should not be seeing these docs!
#[cfg(stage0)]
#[lang="covariant_type"] // only relevant to stage0
pub struct PhantomData<T:?Sized>;
/// `PhantomData` is a way to tell the compiler about fake fields.
/// Phantom data is required whenever type parameters are not used.
/// The idea is that if the compiler encounters a `PhantomData<T>`
@@ -374,14 +349,12 @@ pub struct PhantomData<T:?Sized>;
/// here! For now, please see [RFC 738][738] for more information.
///
/// [738]: https://github.com/rust-lang/rfcs/blob/master/text/0738-variance.md
#[cfg(not(stage0))]
#[lang="phantom_data"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct PhantomData<T:?Sized>;
impls! { PhantomData }
#[cfg(not(stage0))]
mod impls {
use super::{Send, Sync, Sized};
@@ -417,7 +390,6 @@ pub struct ContravariantType<T>;
#[unstable(feature = "core", reason = "deprecated")]
#[deprecated(since = "1.0.0", reason = "Replace with `PhantomData<T>`")]
#[lang="covariant_type"]
#[cfg(not(stage0))]
pub struct CovariantType<T>;
/// Old-style marker trait. Deprecated.