Skip to content

Commit 9fa06cb

Browse files
committed
---
yaml --- r: 105967 b: refs/heads/auto c: e99d523 h: refs/heads/master i: 105965: b6ceaea 105963: fa43801 105959: f1d7cfb 105951: abaaa0f v: v3
1 parent cd784fa commit 9fa06cb

Some content is hidden

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

61 files changed

+826
-181
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: e9bd12169d723352a5073acd16ad932c68460ed2
16+
refs/heads/auto: e99d523707c8058383e7a551e49d59ce622d5765
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#[allow(non_camel_case_types)];
1414
#[deny(warnings)];
15+
#[allow(deprecated_owned_vector)];
1516

1617
extern crate test;
1718
extern crate getopts;

branches/auto/src/libarena/lib.rs

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

2526
extern crate collections;
2627

branches/auto/src/libcollections/hashmap.rs

Lines changed: 90 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,6 @@
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/)
6212
6313
use std::container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
6414
use std::clone::Clone;
@@ -667,14 +617,64 @@ static INITIAL_LOAD_FACTOR: Fraction = (9, 10);
667617
// `table::RawTable::new`, but I'm not confident it works for all sane alignments,
668618
// especially if a type needs more alignment than `malloc` provides.
669619

670-
/// A hash map implementation which uses linear probing with Robin Hood bucket
671-
/// stealing.
620+
/// A hash map implementation which uses linear probing with Robin
621+
/// Hood bucket stealing.
672622
///
673623
/// The hashes are all keyed by the task-local random number generator
674-
/// on creation by default. This can be overriden with one of the constructors.
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.
675628
///
676629
/// It is required that the keys implement the `Eq` and `Hash` traits, although
677630
/// 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,41 +1069,49 @@ 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, 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
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)
10941084
};
10951085

1096-
let probe_dib = self.bucket_distance(&full_index);
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+
}
10971109

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);
1110+
probe = self.probe_next(probe);
11011111
}
11021112

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

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

19491957
#[cfg(test)]
19501958
mod test_set {
1951-
use super::HashMap;
19521959
use super::HashSet;
19531960
use std::container::Container;
19541961
use std::vec::ImmutableEqVector;
@@ -2193,7 +2200,6 @@ mod test_set {
21932200
mod bench {
21942201
extern crate test;
21952202
use self::test::BenchHarness;
2196-
use std::iter;
21972203
use std::iter::{range_inclusive};
21982204

21992205
#[bench]

branches/auto/src/libcollections/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
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)];
2526

2627
extern crate rand;
2728

branches/auto/src/libextra/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ 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)];
3435
#[deny(non_camel_case_types)];
3536
#[deny(missing_doc)];
3637

branches/auto/src/libflate/lib.rs

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

9191
#[cfg(test)]
9292
mod tests {
93+
#[allow(deprecated_owned_vector)];
9394
extern crate rand;
9495

9596
use super::{inflate_bytes, deflate_bytes};

branches/auto/src/libgetopts/lib.rs

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

8586
#[feature(globs)];
8687

branches/auto/src/libglob/lib.rs

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

3132
use std::cell::Cell;
3233
use std::{cmp, os, path};

branches/auto/src/libgreen/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
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)];
177178

178179
extern crate rand;
179180

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ 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+
}
354359
}
355360

356361
impl rtio::RtioSocket for TcpStream {

branches/auto/src/libnative/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
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)];
5354

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

branches/auto/src/libnum/lib.rs

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

1819
extern crate rand;
1920

branches/auto/src/librand/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ 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)];
7475

7576
use std::cast;
7677
use std::kinds::marker;

branches/auto/src/librustc/lib.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ 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)];
3132
#[feature(macro_rules, globs, struct_variant, managed_boxes)];
3233
#[feature(quote, default_type_params)];
3334

@@ -133,6 +134,9 @@ pub mod lib {
133134
pub mod llvmdeps;
134135
}
135136

137+
static BUG_REPORT_URL: &'static str =
138+
"http://static.rust-lang.org/doc/master/complement-bugreport.html";
139+
136140
pub fn version(argv0: &str) {
137141
let vers = match option_env!("CFG_VERSION") {
138142
Some(vers) => vers,
@@ -392,20 +396,31 @@ pub fn monitor(f: proc()) {
392396
// Task failed without emitting a fatal diagnostic
393397
if !value.is::<diagnostic::FatalError>() {
394398
let mut emitter = diagnostic::EmitterWriter::stderr();
395-
emitter.emit(
396-
None,
397-
diagnostic::ice_msg("unexpected failure"),
398-
diagnostic::Error);
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+
}
399408

400409
let xs = [
401-
~"the compiler hit an unexpected failure path. \
402-
this is a bug",
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",
403413
];
404414
for note in xs.iter() {
405415
emitter.emit(None, *note, diagnostic::Note)
406416
}
407417

408-
println!("{}", r.read_to_str());
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+
}
409424
}
410425

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

0 commit comments

Comments
 (0)