Skip to content

Commit

Permalink
auto merge of #11863 : erickt/rust/hash, r=acrichto
Browse files Browse the repository at this point in the history
This PR merges `IterBytes` and `Hash` into a trait that allows for generic non-stream-based hashing. It makes use of @eddyb's default type parameter support in order to have a similar usage to the old `Hash` framework.

Fixes #8038.

Todo:

- [x] Better documentation
- [ ] Benchmark
- [ ] Parameterize `HashMap` on a `Hasher`.
  • Loading branch information
bors committed Feb 22, 2014
2 parents 2ba0a8a + ca6d512 commit 22d3669
Show file tree
Hide file tree
Showing 41 changed files with 1,191 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/etc/generate-deriving-span-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def write_file(name, string):
('Clone', [], 1), ('DeepClone', ['Clone'], 1),
('Eq', [], 2), ('Ord', [], 8),
('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1),
('Show', [], 1)]:
('Show', [], 1),
('Hash', [], 1)]:
traits[trait] = (ALL, supers, errs)

for (trait, (types, super_traits, error_count)) in traits.items():
Expand Down
1 change: 1 addition & 0 deletions src/libextra/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#[allow(missing_doc)];

use std::cmp;
use std::hash_old::Hash;
use std::hashmap;
use std::io;
use std::mem;
Expand Down
1 change: 1 addition & 0 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use middle::typeck;
use middle::astencode::vtable_decoder_helpers;

use std::u64;
use std::hash_old::Hash;
use std::io;
use std::io::extensions::u64_from_be_bytes;
use std::option;
Expand Down
1 change: 1 addition & 0 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use middle;
use serialize::Encodable;
use std::cast;
use std::cell::{Cell, RefCell};
use std::hash_old::Hash;
use std::hashmap::{HashMap, HashSet};
use std::io::MemWriter;
use std::str;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4916,7 +4916,7 @@ pub fn trait_method_of_method(tcx: ctxt,
/// Creates a hash of the type `t` which will be the same no matter what crate
/// context it's calculated within. This is used by the `type_id` intrinsic.
pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
use std::hash::{SipState, Streaming};
use std::hash_old::{SipState, Streaming};

let mut hash = SipState::new(0, 0);
let region = |_hash: &mut SipState, r: Region| {
Expand Down
1 change: 1 addition & 0 deletions src/libserialize/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Core encoding and decoding interfaces.
*/

use std::hash_old::Hash;
use std::hashmap::{HashMap, HashSet};
use std::rc::Rc;
use std::trie::{TrieMap, TrieSet};
Expand Down
Loading

0 comments on commit 22d3669

Please sign in to comment.