Skip to content

Commit cd784fa

Browse files
committed
---
yaml --- r: 105966 b: refs/heads/auto c: e9bd121 h: refs/heads/master v: v3
1 parent b6ceaea commit cd784fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+189
-834
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 2585803ec1c2476d0fbcf384b42f76677434bbb7
16+
refs/heads/auto: e9bd12169d723352a5073acd16ad932c68460ed2
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/compiletest/compiletest.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#[allow(non_camel_case_types)];
1414
#[deny(warnings)];
15-
#[allow(deprecated_owned_vector)];
1615

1716
extern crate test;
1817
extern crate getopts;

branches/auto/src/libarena/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#[license = "MIT/ASL2"];
2222
#[allow(missing_doc)];
2323
#[feature(managed_boxes)];
24-
#[allow(deprecated_owned_vector)];
2524

2625
extern crate collections;
2726

branches/auto/src/libcollections/hashmap.rs

Lines changed: 84 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,56 @@
99
// except according to those terms.
1010

1111
//! Unordered containers, implemented as hash-tables (`HashSet` and `HashMap` types)
12+
//!
13+
//! The tables use a keyed hash with new random keys generated for each container, so the ordering
14+
//! of a set of keys in a hash table is randomized.
15+
//!
16+
//! This is currently implemented with robin hood hashing, as described in [1][2][3].
17+
//!
18+
//! # Example
19+
//!
20+
//! ```rust
21+
//! use collections::HashMap;
22+
//!
23+
//! // type inference lets us omit an explicit type signature (which
24+
//! // would be `HashMap<&str, &str>` in this example).
25+
//! let mut book_reviews = HashMap::new();
26+
//!
27+
//! // review some books.
28+
//! book_reviews.insert("Adventures of Hucklebury Fin", "My favorite book.");
29+
//! book_reviews.insert("Grimms' Fairy Tales", "Masterpiece.");
30+
//! book_reviews.insert("Pride and Prejudice", "Very enjoyable.");
31+
//! book_reviews.insert("The Adventures of Sherlock Holmes", "Eye lyked it alot.");
32+
//!
33+
//! // check for a specific one.
34+
//! if !book_reviews.contains_key(& &"Les Misérables") {
35+
//! println!("We've got {} reviews, but Les Misérables ain't one.",
36+
//! book_reviews.len());
37+
//! }
38+
//!
39+
//! // oops, this review has a lot of spelling mistakes, let's delete it.
40+
//! book_reviews.remove(& &"The Adventures of Sherlock Holmes");
41+
//!
42+
//! // look up the values associated with some keys.
43+
//! let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"];
44+
//! for book in to_find.iter() {
45+
//! match book_reviews.find(book) {
46+
//! Some(review) => println!("{}: {}", *book, *review),
47+
//! None => println!("{} is unreviewed.", *book)
48+
//! }
49+
//! }
50+
//!
51+
//! // iterate over everything.
52+
//! for (book, review) in book_reviews.iter() {
53+
//! println!("{}: \"{}\"", *book, *review);
54+
//! }
55+
//! ```
56+
//!
57+
//! Relevant papers/articles:
58+
//!
59+
//! [1]: Pedro Celis. ["Robin Hood Hashing"](https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf)
60+
//! [2]: (http://codecapsule.com/2013/11/11/robin-hood-hashing/)
61+
//! [3]: (http://codecapsule.com/2013/11/17/robin-hood-hashing-backward-shift-deletion/)
1262
1363
use std::container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
1464
use std::clone::Clone;
@@ -617,64 +667,14 @@ static INITIAL_LOAD_FACTOR: Fraction = (9, 10);
617667
// `table::RawTable::new`, but I'm not confident it works for all sane alignments,
618668
// especially if a type needs more alignment than `malloc` provides.
619669

620-
/// A hash map implementation which uses linear probing with Robin
621-
/// Hood bucket stealing.
670+
/// A hash map implementation which uses linear probing with Robin Hood bucket
671+
/// stealing.
622672
///
623673
/// The hashes are all keyed by the task-local random number generator
624-
/// on creation by default, this means the ordering of the keys is
625-
/// randomized, but makes the tables more resistant to
626-
/// denial-of-service attacks (Hash DoS). This behaviour can be
627-
/// overriden with one of the constructors.
674+
/// on creation by default. This can be overriden with one of the constructors.
628675
///
629676
/// It is required that the keys implement the `Eq` and `Hash` traits, although
630677
/// this can frequently be achieved by using `#[deriving(Eq, Hash)]`.
631-
///
632-
/// Relevant papers/articles:
633-
///
634-
/// 1. Pedro Celis. ["Robin Hood Hashing"](https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf)
635-
/// 2. Emmanuel Goossaert. ["Robin Hood
636-
/// hashing"](http://codecapsule.com/2013/11/11/robin-hood-hashing/)
637-
/// 3. Emmanuel Goossaert. ["Robin Hood hashing: backward shift
638-
/// deletion"](http://codecapsule.com/2013/11/17/robin-hood-hashing-backward-shift-deletion/)
639-
///
640-
/// # Example
641-
///
642-
/// ```rust
643-
/// use collections::HashMap;
644-
///
645-
/// // type inference lets us omit an explicit type signature (which
646-
/// // would be `HashMap<&str, &str>` in this example).
647-
/// let mut book_reviews = HashMap::new();
648-
///
649-
/// // review some books.
650-
/// book_reviews.insert("Adventures of Hucklebury Fin", "My favorite book.");
651-
/// book_reviews.insert("Grimms' Fairy Tales", "Masterpiece.");
652-
/// book_reviews.insert("Pride and Prejudice", "Very enjoyable.");
653-
/// book_reviews.insert("The Adventures of Sherlock Holmes", "Eye lyked it alot.");
654-
///
655-
/// // check for a specific one.
656-
/// if !book_reviews.contains_key(& &"Les Misérables") {
657-
/// println!("We've got {} reviews, but Les Misérables ain't one.",
658-
/// book_reviews.len());
659-
/// }
660-
///
661-
/// // oops, this review has a lot of spelling mistakes, let's delete it.
662-
/// book_reviews.remove(& &"The Adventures of Sherlock Holmes");
663-
///
664-
/// // look up the values associated with some keys.
665-
/// let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"];
666-
/// for book in to_find.iter() {
667-
/// match book_reviews.find(book) {
668-
/// Some(review) => println!("{}: {}", *book, *review),
669-
/// None => println!("{} is unreviewed.", *book)
670-
/// }
671-
/// }
672-
///
673-
/// // iterate over everything.
674-
/// for (book, review) in book_reviews.iter() {
675-
/// println!("{}: \"{}\"", *book, *review);
676-
/// }
677-
/// ```
678678
#[deriving(Clone)]
679679
pub struct HashMap<K, V, H = sip::SipHasher> {
680680
// All hashes are keyed on these values, to prevent hash collision attacks.
@@ -1069,49 +1069,41 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
10691069
/// so we have some sort of upper bound on the number of probes to do.
10701070
///
10711071
/// 'hash', 'k', and 'v' are the elements to robin hood into the hashtable.
1072-
fn robin_hood(&mut self, mut index: table::FullIndex, mut dib_param: uint,
1073-
mut hash: table::SafeHash, mut k: K, mut v: V) {
1074-
'outer: loop {
1075-
let (old_hash, old_key, old_val) = {
1076-
let (old_hash_ref, old_key_ref, old_val_ref) =
1077-
self.table.read_all_mut(&index);
1078-
1079-
let old_hash = replace(old_hash_ref, hash);
1080-
let old_key = replace(old_key_ref, k);
1081-
let old_val = replace(old_val_ref, v);
1082-
1083-
(old_hash, old_key, old_val)
1072+
fn robin_hood(&mut self, index: table::FullIndex, dib_param: uint,
1073+
hash: table::SafeHash, k: K, v: V) {
1074+
let (old_hash, old_key, old_val) = {
1075+
let (old_hash_ref, old_key_ref, old_val_ref) = self.table.read_all_mut(&index);
1076+
1077+
let old_hash = replace(old_hash_ref, hash);
1078+
let old_key = replace(old_key_ref, k);
1079+
let old_val = replace(old_val_ref, v);
1080+
1081+
(old_hash, old_key, old_val)
1082+
};
1083+
1084+
let mut probe = self.probe_next(index.raw_index());
1085+
1086+
for dib in range(dib_param + 1, self.table.size()) {
1087+
let full_index = match self.table.peek(probe) {
1088+
table::Empty(idx) => {
1089+
// Finally. A hole!
1090+
self.table.put(idx, old_hash, old_key, old_val);
1091+
return;
1092+
},
1093+
table::Full(idx) => idx
10841094
};
10851095

1086-
let mut probe = self.probe_next(index.raw_index());
1087-
1088-
for dib in range(dib_param + 1, self.table.size()) {
1089-
let full_index = match self.table.peek(probe) {
1090-
table::Empty(idx) => {
1091-
// Finally. A hole!
1092-
self.table.put(idx, old_hash, old_key, old_val);
1093-
return;
1094-
},
1095-
table::Full(idx) => idx
1096-
};
1097-
1098-
let probe_dib = self.bucket_distance(&full_index);
1099-
1100-
// Robin hood! Steal the spot.
1101-
if probe_dib < dib {
1102-
index = full_index;
1103-
dib_param = probe_dib;
1104-
hash = old_hash;
1105-
k = old_key;
1106-
v = old_val;
1107-
continue 'outer;
1108-
}
1096+
let probe_dib = self.bucket_distance(&full_index);
11091097

1110-
probe = self.probe_next(probe);
1098+
if probe_dib < dib {
1099+
// Robin hood! Steal the spot. This had better be tail call.
1100+
return self.robin_hood(full_index, probe_dib, old_hash, old_key, old_val);
11111101
}
11121102

1113-
fail!("HashMap fatal error: 100% load factor?");
1103+
probe = self.probe_next(probe);
11141104
}
1105+
1106+
fail!("HashMap fatal error: 100% load factor?");
11151107
}
11161108

11171109
/// Manually insert a pre-hashed key-value pair, without first checking
@@ -1956,6 +1948,7 @@ mod test_map {
19561948

19571949
#[cfg(test)]
19581950
mod test_set {
1951+
use super::HashMap;
19591952
use super::HashSet;
19601953
use std::container::Container;
19611954
use std::vec::ImmutableEqVector;
@@ -2200,6 +2193,7 @@ mod test_set {
22002193
mod bench {
22012194
extern crate test;
22022195
use self::test::BenchHarness;
2196+
use std::iter;
22032197
use std::iter::{range_inclusive};
22042198

22052199
#[bench]

branches/auto/src/libcollections/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
// NOTE remove the following two attributes after the next snapshot.
2323
#[allow(unrecognized_lint)];
2424
#[allow(default_type_param_usage)];
25-
#[allow(deprecated_owned_vector)];
2625

2726
extern crate rand;
2827

branches/auto/src/libextra/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Rust extras are part of the standard Rust distribution.
3131

3232
#[feature(macro_rules, globs, managed_boxes, asm, default_type_params)];
3333

34-
#[allow(deprecated_owned_vector)];
3534
#[deny(non_camel_case_types)];
3635
#[deny(missing_doc)];
3736

branches/auto/src/libflate/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ pub fn inflate_bytes_zlib(bytes: &[u8]) -> CVec<u8> {
9090

9191
#[cfg(test)]
9292
mod tests {
93-
#[allow(deprecated_owned_vector)];
9493
extern crate rand;
9594

9695
use super::{inflate_bytes, deflate_bytes};

branches/auto/src/libgetopts/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
#[crate_type = "dylib"];
8282
#[license = "MIT/ASL2"];
8383
#[allow(missing_doc)];
84-
#[allow(deprecated_owned_vector)];
8584

8685
#[feature(globs)];
8786

branches/auto/src/libglob/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#[crate_type = "rlib"];
2828
#[crate_type = "dylib"];
2929
#[license = "MIT/ASL2"];
30-
#[allow(deprecated_owned_vector)];
3130

3231
use std::cell::Cell;
3332
use std::{cmp, os, path};

branches/auto/src/libgreen/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@
174174
// NB this does *not* include globs, please keep it that way.
175175
#[feature(macro_rules)];
176176
#[allow(visible_private_types)];
177-
#[allow(deprecated_owned_vector)];
178177

179178
extern crate rand;
180179

branches/auto/src/libnative/io/net.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,6 @@ impl rtio::RtioTcpStream for TcpStream {
351351
fn clone(&self) -> ~rtio::RtioTcpStream {
352352
~TcpStream { inner: self.inner.clone() } as ~rtio::RtioTcpStream
353353
}
354-
fn close_write(&mut self) -> IoResult<()> {
355-
super::mkerr_libc(unsafe {
356-
libc::shutdown(self.fd(), libc::SHUT_WR)
357-
})
358-
}
359354
}
360355

361356
impl rtio::RtioSocket for TcpStream {

branches/auto/src/libnative/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
html_root_url = "http://static.rust-lang.org/doc/master")];
5151
#[deny(unused_result, unused_must_use)];
5252
#[allow(non_camel_case_types)];
53-
#[allow(deprecated_owned_vector)];
5453

5554
// NB this crate explicitly does *not* allow glob imports, please seriously
5655
// consider whether they're needed before adding that feature here (the

branches/auto/src/libnum/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#[crate_type = "rlib"];
1515
#[crate_type = "dylib"];
1616
#[license = "MIT/ASL2"];
17-
#[allow(deprecated_owned_vector)];
1817

1918
extern crate rand;
2019

branches/auto/src/librand/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ println!("{:?}", tuple_ptr)
7171
html_root_url = "http://static.rust-lang.org/doc/master")];
7272

7373
#[feature(macro_rules, managed_boxes)];
74-
#[allow(deprecated_owned_vector)];
7574

7675
use std::cast;
7776
use std::kinds::marker;

branches/auto/src/librustc/lib.rs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ This API is completely unstable and subject to change.
2828
html_root_url = "http://static.rust-lang.org/doc/master")];
2929

3030
#[allow(deprecated)];
31-
#[allow(deprecated_owned_vector)];
3231
#[feature(macro_rules, globs, struct_variant, managed_boxes)];
3332
#[feature(quote, default_type_params)];
3433

@@ -134,9 +133,6 @@ pub mod lib {
134133
pub mod llvmdeps;
135134
}
136135

137-
static BUG_REPORT_URL: &'static str =
138-
"http://static.rust-lang.org/doc/master/complement-bugreport.html";
139-
140136
pub fn version(argv0: &str) {
141137
let vers = match option_env!("CFG_VERSION") {
142138
Some(vers) => vers,
@@ -396,31 +392,20 @@ pub fn monitor(f: proc()) {
396392
// Task failed without emitting a fatal diagnostic
397393
if !value.is::<diagnostic::FatalError>() {
398394
let mut emitter = diagnostic::EmitterWriter::stderr();
399-
400-
// a .span_bug or .bug call has already printed what
401-
// it wants to print.
402-
if !value.is::<diagnostic::ExplicitBug>() {
403-
emitter.emit(
404-
None,
405-
"unexpected failure",
406-
diagnostic::Bug);
407-
}
395+
emitter.emit(
396+
None,
397+
diagnostic::ice_msg("unexpected failure"),
398+
diagnostic::Error);
408399

409400
let xs = [
410-
~"the compiler hit an unexpected failure path. this is a bug.",
411-
"we would appreciate a bug report: " + BUG_REPORT_URL,
412-
~"run with `RUST_LOG=std::rt::backtrace` for a backtrace",
401+
~"the compiler hit an unexpected failure path. \
402+
this is a bug",
413403
];
414404
for note in xs.iter() {
415405
emitter.emit(None, *note, diagnostic::Note)
416406
}
417407

418-
match r.read_to_str() {
419-
Ok(s) => println!("{}", s),
420-
Err(e) => emitter.emit(None,
421-
format!("failed to read internal stderr: {}", e),
422-
diagnostic::Error),
423-
}
408+
println!("{}", r.read_to_str());
424409
}
425410

426411
// Fail so the process returns a failure code, but don't pollute the

0 commit comments

Comments
 (0)