Auto merge of #36815 - alexcrichton:stabilize-1.13, r=aturon

std: Stabilize and deprecate APIs for 1.13

This commit is intended to be backported to the 1.13 branch, and works with the
following APIs:

Stabilized

* `i32::checked_abs`
* `i32::wrapping_abs`
* `i32::overflowing_abs`
* `RefCell::try_borrow`
* `RefCell::try_borrow_mut`

Deprecated

* `BinaryHeap::push_pop`
* `BinaryHeap::replace`
* `SipHash13`
* `SipHash24`
* `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map`
  module

Closes #28147
Closes #34767
Closes #35057
Closes #35070
This commit is contained in:
bors 2016-10-03 11:00:03 -07:00 committed by GitHub
commit 7a26aeca77
24 changed files with 129 additions and 80 deletions

View File

@ -535,6 +535,7 @@ impl<T: Ord> BinaryHeap<T> {
///
/// ```
/// #![feature(binary_heap_extras)]
/// #![allow(deprecated)]
///
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
@ -549,6 +550,7 @@ impl<T: Ord> BinaryHeap<T> {
#[unstable(feature = "binary_heap_extras",
reason = "needs to be audited",
issue = "28147")]
#[rustc_deprecated(since = "1.13.0", reason = "use `peek_mut` instead")]
pub fn push_pop(&mut self, mut item: T) -> T {
match self.data.get_mut(0) {
None => return item,
@ -575,6 +577,7 @@ impl<T: Ord> BinaryHeap<T> {
///
/// ```
/// #![feature(binary_heap_extras)]
/// #![allow(deprecated)]
///
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
@ -587,6 +590,7 @@ impl<T: Ord> BinaryHeap<T> {
#[unstable(feature = "binary_heap_extras",
reason = "needs to be audited",
issue = "28147")]
#[rustc_deprecated(since = "1.13.0", reason = "use `peek_mut` instead")]
pub fn replace(&mut self, mut item: T) -> Option<T> {
if !self.is_empty() {
swap(&mut item, &mut self.data[0]);

View File

@ -139,6 +139,7 @@ fn test_push_unique() {
}
#[test]
#[allow(deprecated)]
fn test_push_pop() {
let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
assert_eq!(heap.len(), 5);
@ -153,6 +154,7 @@ fn test_push_pop() {
}
#[test]
#[allow(deprecated)]
fn test_replace() {
let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
assert_eq!(heap.len(), 5);
@ -212,6 +214,7 @@ fn test_empty_peek_mut() {
}
#[test]
#[allow(deprecated)]
fn test_empty_replace() {
let mut heap = BinaryHeap::new();
assert!(heap.replace(5).is_none());

View File

@ -31,7 +31,8 @@ extern crate collections;
extern crate test;
extern crate rustc_unicode;
use std::hash::{Hash, Hasher, SipHasher};
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
#[cfg(test)] #[macro_use] mod bench;
@ -47,7 +48,7 @@ mod vec_deque;
mod vec;
fn hash<T: Hash>(t: &T) -> u64 {
let mut s = SipHasher::new();
let mut s = DefaultHasher::new();
t.hash(&mut s);
s.finish()
}

View File

@ -175,7 +175,7 @@
use cmp::Ordering;
use fmt::{self, Debug, Display};
use marker::{PhantomData, Unsize};
use marker::Unsize;
use ops::{Deref, DerefMut, CoerceUnsized};
/// A mutable memory location that admits only `Copy` data.
@ -403,40 +403,40 @@ pub enum BorrowState {
}
/// An error returned by [`RefCell::try_borrow`](struct.RefCell.html#method.try_borrow).
#[unstable(feature = "try_borrow", issue = "35070")]
pub struct BorrowError<'a, T: 'a + ?Sized> {
marker: PhantomData<&'a RefCell<T>>,
#[stable(feature = "try_borrow", since = "1.13.0")]
pub struct BorrowError {
_private: (),
}
#[unstable(feature = "try_borrow", issue = "35070")]
impl<'a, T: ?Sized> Debug for BorrowError<'a, T> {
#[stable(feature = "try_borrow", since = "1.13.0")]
impl Debug for BorrowError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("BorrowError").finish()
}
}
#[unstable(feature = "try_borrow", issue = "35070")]
impl<'a, T: ?Sized> Display for BorrowError<'a, T> {
#[stable(feature = "try_borrow", since = "1.13.0")]
impl Display for BorrowError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Display::fmt("already mutably borrowed", f)
}
}
/// An error returned by [`RefCell::try_borrow_mut`](struct.RefCell.html#method.try_borrow_mut).
#[unstable(feature = "try_borrow", issue = "35070")]
pub struct BorrowMutError<'a, T: 'a + ?Sized> {
marker: PhantomData<&'a RefCell<T>>,
#[stable(feature = "try_borrow", since = "1.13.0")]
pub struct BorrowMutError {
_private: (),
}
#[unstable(feature = "try_borrow", issue = "35070")]
impl<'a, T: ?Sized> Debug for BorrowMutError<'a, T> {
#[stable(feature = "try_borrow", since = "1.13.0")]
impl Debug for BorrowMutError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("BorrowMutError").finish()
}
}
#[unstable(feature = "try_borrow", issue = "35070")]
impl<'a, T: ?Sized> Display for BorrowMutError<'a, T> {
#[stable(feature = "try_borrow", since = "1.13.0")]
impl Display for BorrowMutError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Display::fmt("already borrowed", f)
}
@ -573,8 +573,6 @@ impl<T: ?Sized> RefCell<T> {
/// # Examples
///
/// ```
/// #![feature(try_borrow)]
///
/// use std::cell::RefCell;
///
/// let c = RefCell::new(5);
@ -589,15 +587,15 @@ impl<T: ?Sized> RefCell<T> {
/// assert!(c.try_borrow().is_ok());
/// }
/// ```
#[unstable(feature = "try_borrow", issue = "35070")]
#[stable(feature = "try_borrow", since = "1.13.0")]
#[inline]
pub fn try_borrow(&self) -> Result<Ref<T>, BorrowError<T>> {
pub fn try_borrow(&self) -> Result<Ref<T>, BorrowError> {
match BorrowRef::new(&self.borrow) {
Some(b) => Ok(Ref {
value: unsafe { &*self.value.get() },
borrow: b,
}),
None => Err(BorrowError { marker: PhantomData }),
None => Err(BorrowError { _private: () }),
}
}
@ -654,8 +652,6 @@ impl<T: ?Sized> RefCell<T> {
/// # Examples
///
/// ```
/// #![feature(try_borrow)]
///
/// use std::cell::RefCell;
///
/// let c = RefCell::new(5);
@ -667,15 +663,15 @@ impl<T: ?Sized> RefCell<T> {
///
/// assert!(c.try_borrow_mut().is_ok());
/// ```
#[unstable(feature = "try_borrow", issue = "35070")]
#[stable(feature = "try_borrow", since = "1.13.0")]
#[inline]
pub fn try_borrow_mut(&self) -> Result<RefMut<T>, BorrowMutError<T>> {
pub fn try_borrow_mut(&self) -> Result<RefMut<T>, BorrowMutError> {
match BorrowRefMut::new(&self.borrow) {
Some(b) => Ok(RefMut {
value: unsafe { &mut *self.value.get() },
borrow: b,
}),
None => Err(BorrowMutError { marker: PhantomData }),
None => Err(BorrowMutError { _private: () }),
}
}

View File

@ -76,9 +76,11 @@ use marker;
use mem;
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub use self::sip::SipHasher;
#[unstable(feature = "sip_hash_13", issue = "29754")]
#[allow(deprecated)]
pub use self::sip::{SipHasher13, SipHasher24};
mod sip;

View File

@ -10,6 +10,8 @@
//! An implementation of SipHash.
#![allow(deprecated)]
use marker::PhantomData;
use ptr;
@ -17,6 +19,7 @@ use ptr;
///
/// See: https://131002.net/siphash/
#[unstable(feature = "sip_hash_13", issue = "34767")]
#[rustc_deprecated(since = "1.13.0", reason = "use `DefaultHasher` instead")]
#[derive(Debug, Clone, Default)]
pub struct SipHasher13 {
hasher: Hasher<Sip13Rounds>,
@ -26,6 +29,7 @@ pub struct SipHasher13 {
///
/// See: https://131002.net/siphash/
#[unstable(feature = "sip_hash_13", issue = "34767")]
#[rustc_deprecated(since = "1.13.0", reason = "use `DefaultHasher` instead")]
#[derive(Debug, Clone, Default)]
pub struct SipHasher24 {
hasher: Hasher<Sip24Rounds>,
@ -47,6 +51,7 @@ pub struct SipHasher24 {
/// it is not intended for cryptographic purposes. As such, all
/// cryptographic uses of this implementation are _strongly discouraged_.
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.13.0", reason = "use `DefaultHasher` instead")]
#[derive(Debug, Clone, Default)]
pub struct SipHasher(SipHasher24);
@ -136,6 +141,7 @@ impl SipHasher {
/// Creates a new `SipHasher` with the two initial keys set to 0.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.13.0", reason = "use `DefaultHasher` instead")]
pub fn new() -> SipHasher {
SipHasher::new_with_keys(0, 0)
}
@ -143,16 +149,17 @@ impl SipHasher {
/// Creates a `SipHasher` that is keyed off the provided keys.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.13.0", reason = "use `DefaultHasher` instead")]
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher {
SipHasher(SipHasher24::new_with_keys(key0, key1))
}
}
impl SipHasher13 {
/// Creates a new `SipHasher13` with the two initial keys set to 0.
#[inline]
#[unstable(feature = "sip_hash_13", issue = "34767")]
#[rustc_deprecated(since = "1.13.0", reason = "use `DefaultHasher` instead")]
pub fn new() -> SipHasher13 {
SipHasher13::new_with_keys(0, 0)
}
@ -160,6 +167,7 @@ impl SipHasher13 {
/// Creates a `SipHasher13` that is keyed off the provided keys.
#[inline]
#[unstable(feature = "sip_hash_13", issue = "34767")]
#[rustc_deprecated(since = "1.13.0", reason = "use `DefaultHasher` instead")]
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher13 {
SipHasher13 {
hasher: Hasher::new_with_keys(key0, key1)
@ -171,6 +179,7 @@ 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 `DefaultHasher` instead")]
pub fn new() -> SipHasher24 {
SipHasher24::new_with_keys(0, 0)
}
@ -178,6 +187,7 @@ impl SipHasher24 {
/// 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 `DefaultHasher` instead")]
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher24 {
SipHasher24 {
hasher: Hasher::new_with_keys(key0, key1)

View File

@ -613,14 +613,12 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// # #![feature(no_panic_abs)]
///
/// use std::i32;
///
/// assert_eq!((-5i32).checked_abs(), Some(5));
/// assert_eq!(i32::MIN.checked_abs(), None);
/// ```
#[unstable(feature = "no_panic_abs", issue = "35057")]
#[stable(feature = "no_panic_abs", since = "1.13.0")]
#[inline]
pub fn checked_abs(self) -> Option<Self> {
if self.is_negative() {
@ -895,14 +893,12 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// # #![feature(no_panic_abs)]
///
/// assert_eq!(100i8.wrapping_abs(), 100);
/// assert_eq!((-100i8).wrapping_abs(), 100);
/// assert_eq!((-128i8).wrapping_abs(), -128);
/// assert_eq!((-128i8).wrapping_abs() as u8, 128);
/// ```
#[unstable(feature = "no_panic_abs", issue = "35057")]
#[stable(feature = "no_panic_abs", since = "1.13.0")]
#[inline(always)]
pub fn wrapping_abs(self) -> Self {
if self.is_negative() {
@ -1133,13 +1129,11 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// # #![feature(no_panic_abs)]
///
/// assert_eq!(10i8.overflowing_abs(), (10,false));
/// assert_eq!((-10i8).overflowing_abs(), (10,false));
/// assert_eq!((-128i8).overflowing_abs(), (-128,true));
/// ```
#[unstable(feature = "no_panic_abs", issue = "35057")]
#[stable(feature = "no_panic_abs", since = "1.13.0")]
#[inline]
pub fn overflowing_abs(self) -> (Self, bool) {
if self.is_negative() {

View File

@ -7,6 +7,9 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(deprecated)]
use test::{Bencher, black_box};
use core::hash::{Hash, Hasher};

View File

@ -11,7 +11,8 @@
use hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE};
use rustc_data_structures::fnv::FnvHashMap;
use std::fmt::Write;
use std::hash::{Hash, Hasher, SipHasher};
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
use syntax::ast;
use syntax::parse::token::{self, InternedString};
use ty::TyCtxt;
@ -130,7 +131,7 @@ impl DefPath {
}
pub fn deterministic_hash(&self, tcx: TyCtxt) -> u64 {
let mut state = SipHasher::new();
let mut state = DefaultHasher::new();
self.deterministic_hash_to(tcx, &mut state);
state.finish()
}

View File

@ -39,7 +39,8 @@ use std::collections::btree_map::Keys as BTreeMapKeysIter;
use std::collections::btree_map::Values as BTreeMapValuesIter;
use std::fmt;
use std::hash::{Hasher, SipHasher};
use std::hash::Hasher;
use std::collections::hash_map::DefaultHasher;
use std::iter::FromIterator;
use std::path::PathBuf;
@ -212,7 +213,7 @@ macro_rules! top_level_options {
$warn_text,
self.error_format)*]);
})*
let mut hasher = SipHasher::new();
let mut hasher = DefaultHasher::new();
dep_tracking::stable_hash(sub_hashes,
&mut hasher,
self.error_format);
@ -572,7 +573,7 @@ macro_rules! options {
impl<'a> dep_tracking::DepTrackingHash for $struct_name {
fn hash(&self, hasher: &mut SipHasher, error_format: ErrorOutputType) {
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
let mut sub_hashes = BTreeMap::new();
$({
hash_option!($opt,
@ -1657,21 +1658,22 @@ mod dep_tracking {
use middle::cstore;
use session::search_paths::{PathKind, SearchPaths};
use std::collections::BTreeMap;
use std::hash::{Hash, SipHasher};
use std::hash::Hash;
use std::path::PathBuf;
use std::collections::hash_map::DefaultHasher;
use super::{Passes, CrateType, OptLevel, DebugInfoLevel,
OutputTypes, Externs, ErrorOutputType};
use syntax::feature_gate::UnstableFeatures;
use rustc_back::PanicStrategy;
pub trait DepTrackingHash {
fn hash(&self, &mut SipHasher, ErrorOutputType);
fn hash(&self, &mut DefaultHasher, ErrorOutputType);
}
macro_rules! impl_dep_tracking_hash_via_hash {
($t:ty) => (
impl DepTrackingHash for $t {
fn hash(&self, hasher: &mut SipHasher, _: ErrorOutputType) {
fn hash(&self, hasher: &mut DefaultHasher, _: ErrorOutputType) {
Hash::hash(self, hasher);
}
}
@ -1681,7 +1683,7 @@ mod dep_tracking {
macro_rules! impl_dep_tracking_hash_for_sortable_vec_of {
($t:ty) => (
impl DepTrackingHash for Vec<$t> {
fn hash(&self, hasher: &mut SipHasher, error_format: ErrorOutputType) {
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
let mut elems: Vec<&$t> = self.iter().collect();
elems.sort();
Hash::hash(&elems.len(), hasher);
@ -1720,7 +1722,7 @@ mod dep_tracking {
impl_dep_tracking_hash_for_sortable_vec_of!((String, cstore::NativeLibraryKind));
impl DepTrackingHash for SearchPaths {
fn hash(&self, hasher: &mut SipHasher, _: ErrorOutputType) {
fn hash(&self, hasher: &mut DefaultHasher, _: ErrorOutputType) {
let mut elems: Vec<_> = self
.iter(PathKind::All)
.collect();
@ -1733,7 +1735,7 @@ mod dep_tracking {
where T1: DepTrackingHash,
T2: DepTrackingHash
{
fn hash(&self, hasher: &mut SipHasher, error_format: ErrorOutputType) {
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
Hash::hash(&0, hasher);
DepTrackingHash::hash(&self.0, hasher, error_format);
Hash::hash(&1, hasher);
@ -1743,7 +1745,7 @@ mod dep_tracking {
// This is a stable hash because BTreeMap is a sorted container
pub fn stable_hash(sub_hashes: BTreeMap<&'static str, &DepTrackingHash>,
hasher: &mut SipHasher,
hasher: &mut DefaultHasher,
error_format: ErrorOutputType) {
for (key, sub_hash) in sub_hashes {
// Using Hash::hash() instead of DepTrackingHash::hash() is fine for

View File

@ -24,7 +24,8 @@ use ty::TypeVariants::*;
use rustc_const_math::{ConstInt, ConstIsize, ConstUsize};
use std::cmp;
use std::hash::{Hash, SipHasher, Hasher};
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
use std::intrinsics;
use syntax::ast::{self, Name};
use syntax::attr::{self, SignedInt, UnsignedInt};
@ -353,7 +354,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Creates a hash of the type `Ty` which will be the same no matter what crate
/// context it's calculated within. This is used by the `type_id` intrinsic.
pub fn type_id_hash(self, ty: Ty<'tcx>) -> u64 {
let mut hasher = TypeIdHasher::new(self, SipHasher::new());
let mut hasher = TypeIdHasher::new(self, DefaultHasher::default());
hasher.visit_ty(ty);
hasher.finish()
}

View File

@ -291,7 +291,8 @@ macro_rules! bitflags {
#[cfg(test)]
#[allow(non_upper_case_globals)]
mod tests {
use std::hash::{Hash, Hasher, SipHasher};
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
use std::option::Option::{None, Some};
bitflags! {
@ -492,7 +493,7 @@ mod tests {
}
fn hash<T: Hash>(t: &T) -> u64 {
let mut s = SipHasher::new();
let mut s = DefaultHasher::new();
t.hash(&mut s);
s.finish()
}

View File

@ -29,7 +29,8 @@
use syntax::ast;
use std::cell::RefCell;
use std::hash::{Hash, SipHasher, Hasher};
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
use rustc::dep_graph::DepNode;
use rustc::hir;
use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
@ -126,9 +127,9 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
{
assert!(def_id.is_local());
debug!("HashItemsVisitor::calculate(def_id={:?})", def_id);
// FIXME: this should use SHA1, not SipHash. SipHash is not
// FIXME: this should use SHA1, not DefaultHasher. DefaultHasher is not
// built to avoid collisions.
let mut state = SipHasher::new();
let mut state = DefaultHasher::new();
walk_op(&mut StrictVersionHashVisitor::new(&mut state,
self.tcx,
&mut self.def_path_hashes,
@ -142,7 +143,7 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
fn compute_crate_hash(&mut self) {
let krate = self.tcx.map.krate();
let mut crate_state = SipHasher::new();
let mut crate_state = DefaultHasher::new();
let crate_disambiguator = self.tcx.sess.local_crate_disambiguator();
"crate_disambiguator".hash(&mut crate_state);

View File

@ -25,7 +25,8 @@ use rustc::hir::def_id::DefId;
use rustc::hir::intravisit as visit;
use rustc::ty::TyCtxt;
use rustc_data_structures::fnv;
use std::hash::{Hash, SipHasher};
use std::hash::Hash;
use std::collections::hash_map::DefaultHasher;
use super::def_path_hash::DefPathHashes;
use super::caching_codemap_view::CachingCodemapView;
@ -42,7 +43,7 @@ const IGNORED_ATTRIBUTES: &'static [&'static str] = &[
pub struct StrictVersionHashVisitor<'a, 'hash: 'a, 'tcx: 'hash> {
pub tcx: TyCtxt<'hash, 'tcx, 'tcx>,
pub st: &'a mut SipHasher,
pub st: &'a mut DefaultHasher,
// collect a deterministic hash of def-ids that we have seen
def_path_hashes: &'a mut DefPathHashes<'hash, 'tcx>,
hash_spans: bool,
@ -50,7 +51,7 @@ pub struct StrictVersionHashVisitor<'a, 'hash: 'a, 'tcx: 'hash> {
}
impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
pub fn new(st: &'a mut SipHasher,
pub fn new(st: &'a mut DefaultHasher,
tcx: TyCtxt<'hash, 'tcx, 'tcx>,
def_path_hashes: &'a mut DefPathHashes<'hash, 'tcx>,
codemap: &'a mut CachingCodemapView<'tcx>,

View File

@ -656,13 +656,14 @@ fn crate_path(sess: &Session,
crate_name: &str,
crate_disambiguator: &str)
-> PathBuf {
use std::hash::{SipHasher, Hasher, Hash};
use std::hash::{Hasher, Hash};
use std::collections::hash_map::DefaultHasher;
let incr_dir = sess.opts.incremental.as_ref().unwrap().clone();
// The full crate disambiguator is really long. A hash of it should be
// sufficient.
let mut hasher = SipHasher::new();
let mut hasher = DefaultHasher::new();
crate_disambiguator.hash(&mut hasher);
let crate_name = format!("{}-{}", crate_name, encode_base_36(hasher.finish()));

View File

@ -16,10 +16,11 @@ use rustc::ty::TyCtxt;
use rustc_data_structures::fnv::FnvHashMap;
use rustc_serialize::Encodable as RustcEncodable;
use rustc_serialize::opaque::Encoder;
use std::hash::{Hash, Hasher, SipHasher};
use std::hash::{Hash, Hasher};
use std::io::{self, Cursor, Write};
use std::fs::{self, File};
use std::path::PathBuf;
use std::collections::hash_map::DefaultHasher;
use IncrementalHashesMap;
use super::data::*;
@ -241,7 +242,7 @@ pub fn encode_metadata_hashes(tcx: TyCtxt,
.collect();
hashes.sort();
let mut state = SipHasher::new();
let mut state = DefaultHasher::new();
hashes.hash(&mut state);
let hash = state.finish();

View File

@ -35,6 +35,7 @@ use rustc::session::Session;
use rustc::ty::{self, TyCtxt, ImplOrTraitItem, ImplOrTraitItemContainer};
use std::collections::HashSet;
use std::collections::hash_map::DefaultHasher;
use std::hash::*;
use syntax::ast::{self, NodeId, PatKind, Attribute, CRATE_NODE_ID};
@ -1064,7 +1065,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
None => return,
Some(data) => data,
};
let mut hasher = SipHasher::new();
let mut hasher = DefaultHasher::new();
data.callee_span.hash(&mut hasher);
let hash = hasher.finish();
let qualname = format!("{}::{}", data.name, hash);

View File

@ -127,8 +127,9 @@ use rustc::session::config::NUMBERED_CODEGEN_UNIT_MARKER;
use rustc::ty::TyCtxt;
use rustc::ty::item_path::characteristic_def_id_of_type;
use std::cmp::Ordering;
use std::hash::{Hash, Hasher, SipHasher};
use std::hash::{Hash, Hasher};
use std::sync::Arc;
use std::collections::hash_map::DefaultHasher;
use symbol_map::SymbolMap;
use syntax::ast::NodeId;
use syntax::parse::token::{self, InternedString};
@ -188,7 +189,7 @@ impl<'tcx> CodegenUnit<'tcx> {
}
pub fn compute_symbol_name_hash(&self, tcx: TyCtxt, symbol_map: &SymbolMap) -> u64 {
let mut state = SipHasher::new();
let mut state = DefaultHasher::new();
let all_items = self.items_in_deterministic_order(tcx, symbol_map);
for (item, _) in all_items {
let symbol_name = symbol_map.get(item).unwrap();

View File

@ -14,6 +14,7 @@ use self::VacantEntryState::*;
use borrow::Borrow;
use cmp::max;
use fmt::{self, Debug};
#[allow(deprecated)]
use hash::{Hash, Hasher, BuildHasher, SipHasher13};
use iter::{FromIterator, FusedIterator};
use mem::{self, replace};
@ -2018,6 +2019,7 @@ impl RandomState {
impl BuildHasher for RandomState {
type Hasher = DefaultHasher;
#[inline]
#[allow(deprecated)]
fn build_hasher(&self) -> DefaultHasher {
DefaultHasher(SipHasher13::new_with_keys(self.k0, self.k1))
}
@ -2030,10 +2032,32 @@ impl BuildHasher for RandomState {
///
/// [`RandomState`]: struct.RandomState.html
/// [`Hasher`]: ../../hash/trait.Hasher.html
#[unstable(feature = "hashmap_default_hasher", issue = "0")]
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
#[allow(deprecated)]
#[derive(Debug)]
pub struct DefaultHasher(SipHasher13);
#[unstable(feature = "hashmap_default_hasher", issue = "0")]
impl DefaultHasher {
/// Creates a new `DefaultHasher`.
///
/// This hasher is not guaranteed to be the same as all other
/// `DefaultHasher` instances, but is the same as all other `DefaultHasher`
/// instances created through `new` or `default`.
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
#[allow(deprecated)]
pub fn new() -> DefaultHasher {
DefaultHasher(SipHasher13::new_with_keys(0, 0))
}
}
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
impl Default for DefaultHasher {
fn default() -> DefaultHasher {
DefaultHasher::new()
}
}
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
impl Hasher for DefaultHasher {
#[inline]
fn write(&mut self, msg: &[u8]) {

View File

@ -288,15 +288,15 @@ impl Error for fmt::Error {
}
}
#[unstable(feature = "try_borrow", issue = "35070")]
impl<'a, T: ?Sized + Reflect> Error for cell::BorrowError<'a, T> {
#[stable(feature = "try_borrow", since = "1.13.0")]
impl Error for cell::BorrowError {
fn description(&self) -> &str {
"already mutably borrowed"
}
}
#[unstable(feature = "try_borrow", issue = "35070")]
impl<'a, T: ?Sized + Reflect> Error for cell::BorrowMutError<'a, T> {
#[stable(feature = "try_borrow", since = "1.13.0")]
impl Error for cell::BorrowMutError {
fn description(&self) -> &str {
"already borrowed"
}

View File

@ -726,7 +726,8 @@ mod tests {
use super::*;
use os::raw::c_char;
use borrow::Cow::{Borrowed, Owned};
use hash::{SipHasher, Hash, Hasher};
use hash::{Hash, Hasher};
use collections::hash_map::DefaultHasher;
#[test]
fn c_to_rust() {
@ -808,10 +809,10 @@ mod tests {
let ptr = data.as_ptr() as *const c_char;
let cstr: &'static CStr = unsafe { CStr::from_ptr(ptr) };
let mut s = SipHasher::new_with_keys(0, 0);
let mut s = DefaultHasher::new();
cstr.hash(&mut s);
let cstr_hash = s.finish();
let mut s = SipHasher::new_with_keys(0, 0);
let mut s = DefaultHasher::new();
CString::new(&data[..data.len() - 1]).unwrap().hash(&mut s);
let cstring_hash = s.finish();

View File

@ -273,7 +273,6 @@
#![feature(str_utf16)]
#![feature(test, rustc_private)]
#![feature(thread_local)]
#![feature(try_borrow)]
#![feature(try_from)]
#![feature(unboxed_closures)]
#![feature(unicode)]

View File

@ -3387,10 +3387,11 @@ mod tests {
#[test]
pub fn test_compare() {
use hash::{Hash, Hasher, SipHasher};
use hash::{Hash, Hasher};
use collections::hash_map::DefaultHasher;
fn hash<T: Hash>(t: T) -> u64 {
let mut s = SipHasher::new_with_keys(0, 0);
let mut s = DefaultHasher::new();
t.hash(&mut s);
s.finish()
}

View File

@ -24,7 +24,7 @@ struct Test {
const TEST_REPOS: &'static [Test] = &[Test {
name: "cargo",
repo: "https://github.com/rust-lang/cargo",
sha: "2d85908217f99a30aa5f68e05a8980704bb71fad",
sha: "d8936af1390ab0844e5e68b459214f2529c9f647",
lock: None,
},
Test {