Skip to content

Commit b6ceaea

Browse files
committed
---
yaml --- r: 105965 b: refs/heads/auto c: 2585803 h: refs/heads/master i: 105963: fa43801 v: v3
1 parent 89a13f1 commit b6ceaea

File tree

8 files changed

+198
-60
lines changed

8 files changed

+198
-60
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: eb69eb36f8c94d97546f2937e134e93d2f0dcb55
16+
refs/heads/auto: 2585803ec1c2476d0fbcf384b42f76677434bbb7
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libcollections/hashmap.rs

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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/librustc/lib.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ pub mod lib {
134134
pub mod llvmdeps;
135135
}
136136

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

401409
let xs = [
402-
~"the compiler hit an unexpected failure path. \
403-
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",
404413
];
405414
for note in xs.iter() {
406415
emitter.emit(None, *note, diagnostic::Note)
407416
}
408417

409-
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+
}
410424
}
411425

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

branches/auto/src/librustc/middle/trans/common.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ pub fn return_type_is_void(ccx: &CrateContext, ty: ty::t) -> bool {
103103
ty::type_is_nil(ty) || ty::type_is_bot(ty) || ty::type_is_empty(ccx.tcx, ty)
104104
}
105105

106+
/// Generates a unique symbol based off the name given. This is used to create
107+
/// unique symbols for things like closures.
106108
pub fn gensym_name(name: &str) -> PathElem {
107-
PathName(token::gensym(name))
109+
let num = token::gensym(name);
110+
// use one colon which will get translated to a period by the mangler, and
111+
// we're guaranteed that `num` is globally unique for this crate.
112+
PathName(token::gensym(format!("{}:{}", name, num)))
108113
}
109114

110115
pub struct tydesc_info {

branches/auto/src/libstd/option.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,13 @@ impl<T> Option<T> {
295295

296296
/// Applies a function zero or more times until the result is `None`.
297297
#[inline]
298-
pub fn while_some(self, blk: |v: T| -> Option<T>) {
298+
pub fn while_some(self, f: |v: T| -> Option<T>) {
299299
let mut opt = self;
300-
while opt.is_some() {
301-
opt = blk(opt.unwrap());
300+
loop {
301+
match opt {
302+
Some(x) => opt = f(x),
303+
None => break
304+
}
302305
}
303306
}
304307

branches/auto/src/libstd/rt/backtrace.rs

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,47 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
9191
rest = rest.slice_from(1);
9292
}
9393
let i: uint = from_str(s.slice_to(s.len() - rest.len())).unwrap();
94-
try!(writer.write_str(rest.slice_to(i)));
9594
s = rest.slice_from(i);
95+
rest = rest.slice_to(i);
96+
loop {
97+
if rest.starts_with("$") {
98+
macro_rules! demangle(
99+
($($pat:expr => $demangled:expr),*) => ({
100+
$(if rest.starts_with($pat) {
101+
try!(writer.write_str($demangled));
102+
rest = rest.slice_from($pat.len());
103+
} else)*
104+
{
105+
try!(writer.write_str(rest));
106+
break;
107+
}
108+
109+
})
110+
)
111+
// see src/librustc/back/link.rs for these mappings
112+
demangle! (
113+
"$SP$" => "@",
114+
"$UP$" => "~",
115+
"$RP$" => "*",
116+
"$BP$" => "&",
117+
"$LT$" => "<",
118+
"$GT$" => ">",
119+
"$LP$" => "(",
120+
"$RP$" => ")",
121+
"$C$" => ",",
122+
123+
// in theory we can demangle any unicode code point, but
124+
// for simplicity we just catch the common ones.
125+
"$x20" => " ",
126+
"$x27" => "'",
127+
"$x5b" => "[",
128+
"$x5d" => "]"
129+
)
130+
} else {
131+
try!(writer.write_str(rest));
132+
break;
133+
}
134+
}
96135
}
97136
}
98137

@@ -698,17 +737,25 @@ mod test {
698737
use io::MemWriter;
699738
use str;
700739

740+
macro_rules! t( ($a:expr, $b:expr) => ({
741+
let mut m = MemWriter::new();
742+
super::demangle(&mut m, $a).unwrap();
743+
assert_eq!(str::from_utf8_owned(m.unwrap()).unwrap(), $b.to_owned());
744+
}) )
745+
701746
#[test]
702747
fn demangle() {
703-
macro_rules! t( ($a:expr, $b:expr) => ({
704-
let mut m = MemWriter::new();
705-
super::demangle(&mut m, $a);
706-
assert_eq!(str::from_utf8_owned(m.unwrap()).unwrap(), $b.to_owned());
707-
}) )
708-
709748
t!("test", "test");
710749
t!("_ZN4testE", "test");
711750
t!("_ZN4test", "_ZN4test");
712751
t!("_ZN4test1a2bcE", "test::a::bc");
713752
}
753+
754+
#[test]
755+
fn demangle_dollars() {
756+
t!("_ZN4$UP$E", "~");
757+
t!("_ZN8$UP$testE", "~test");
758+
t!("_ZN8$UP$test4foobE", "~test::foob");
759+
t!("_ZN8$x20test4foobE", " test::foob");
760+
}
714761
}

branches/auto/src/libsyntax/diagnostic.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ use std::io;
1717
use std::iter::range;
1818
use term;
1919

20-
static BUG_REPORT_URL: &'static str =
21-
"http://static.rust-lang.org/doc/master/complement-bugreport.html";
2220
// maximum number of lines we will print for each error; arbitrary.
2321
static MAX_LINES: uint = 6u;
2422

@@ -34,6 +32,10 @@ pub trait Emitter {
3432
/// how a rustc task died (if so desired).
3533
pub struct FatalError;
3634

35+
/// Signifies that the compiler died with an explicit call to `.bug`
36+
/// or `.span_bug` rather than a failed assertion, etc.
37+
pub struct ExplicitBug;
38+
3739
// a span-handler is like a handler but also
3840
// accepts span information for source-location
3941
// reporting.
@@ -61,7 +63,8 @@ impl SpanHandler {
6163
self.handler.custom_emit(&*self.cm, sp, msg, Note);
6264
}
6365
pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
64-
self.span_fatal(sp, ice_msg(msg));
66+
self.handler.emit(Some((&*self.cm, sp)), msg, Bug);
67+
fail!(ExplicitBug);
6568
}
6669
pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
6770
self.span_bug(sp, ~"unimplemented " + msg);
@@ -116,7 +119,8 @@ impl Handler {
116119
self.emit.borrow_mut().get().emit(None, msg, Note);
117120
}
118121
pub fn bug(&self, msg: &str) -> ! {
119-
self.fatal(ice_msg(msg));
122+
self.emit.borrow_mut().get().emit(None, msg, Bug);
123+
fail!(ExplicitBug);
120124
}
121125
pub fn unimpl(&self, msg: &str) -> ! {
122126
self.bug(~"unimplemented " + msg);
@@ -133,11 +137,6 @@ impl Handler {
133137
}
134138
}
135139
136-
pub fn ice_msg(msg: &str) -> ~str {
137-
format!("internal compiler error: {}\nThis message reflects a bug in the Rust compiler. \
138-
\nWe would appreciate a bug report: {}", msg, BUG_REPORT_URL)
139-
}
140-
141140
pub fn mk_span_handler(handler: @Handler, cm: @codemap::CodeMap)
142141
-> @SpanHandler {
143142
@SpanHandler {
@@ -159,6 +158,7 @@ pub fn mk_handler(e: ~Emitter) -> @Handler {
159158
160159
#[deriving(Eq)]
161160
pub enum Level {
161+
Bug,
162162
Fatal,
163163
Error,
164164
Warning,
@@ -170,6 +170,7 @@ impl fmt::Show for Level {
170170
use std::fmt::Show;
171171
172172
match *self {
173+
Bug => "error: internal compiler error".fmt(f),
173174
Fatal | Error => "error".fmt(f),
174175
Warning => "warning".fmt(f),
175176
Note => "note".fmt(f),
@@ -180,7 +181,7 @@ impl fmt::Show for Level {
180181
impl Level {
181182
fn color(self) -> term::color::Color {
182183
match self {
183-
Fatal | Error => term::color::BRIGHT_RED,
184+
Bug | Fatal | Error => term::color::BRIGHT_RED,
184185
Warning => term::color::BRIGHT_YELLOW,
185186
Note => term::color::BRIGHT_GREEN
186187
}

0 commit comments

Comments
 (0)