Skip to content

Commit 89a13f1

Browse files
committed
---
yaml --- r: 105964 b: refs/heads/auto c: eb69eb3 h: refs/heads/master v: v3
1 parent fa43801 commit 89a13f1

File tree

18 files changed

+296
-209
lines changed

18 files changed

+296
-209
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: 339f8163d643ff98df897572a9cfb395cb6496b2
16+
refs/heads/auto: eb69eb36f8c94d97546f2937e134e93d2f0dcb55
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: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -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/librustc/lib.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ 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-
140137
pub fn version(argv0: &str) {
141138
let vers = match option_env!("CFG_VERSION") {
142139
Some(vers) => vers,
@@ -396,31 +393,20 @@ pub fn monitor(f: proc()) {
396393
// Task failed without emitting a fatal diagnostic
397394
if !value.is::<diagnostic::FatalError>() {
398395
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-
}
396+
emitter.emit(
397+
None,
398+
diagnostic::ice_msg("unexpected failure"),
399+
diagnostic::Error);
408400

409401
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",
402+
~"the compiler hit an unexpected failure path. \
403+
this is a bug",
413404
];
414405
for note in xs.iter() {
415406
emitter.emit(None, *note, diagnostic::Note)
416407
}
417408

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-
}
409+
println!("{}", r.read_to_str());
424410
}
425411

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

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,8 @@ 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.
108106
pub fn gensym_name(name: &str) -> PathElem {
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)))
107+
PathName(token::gensym(name))
113108
}
114109

115110
pub struct tydesc_info {

branches/auto/src/librustc/middle/typeck/astconv.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -640,13 +640,11 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
640640
tcx.sess.span_bug(ast_ty.span, "typeof is reserved but unimplemented");
641641
}
642642
ast::TyInfer => {
643-
// ty_infer should only appear as the type of arguments or return
644-
// values in a fn_expr, or as the type of local variables. Both of
645-
// these cases are handled specially and should not descend into this
646-
// routine.
647-
this.tcx().sess.span_bug(
648-
ast_ty.span,
649-
"found `ty_infer` in unexpected place");
643+
// TyInfer also appears as the type of arguments or return
644+
// values in a ExprFnBlock or ExprProc, or as the type of
645+
// local variables. Both of these cases are handled specially
646+
// and will not descend into this routine.
647+
this.ty_infer(ast_ty.span)
650648
}
651649
});
652650

branches/auto/src/librustc/middle/typeck/collect.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ impl AstConv for CrateCtxt {
132132
}
133133

134134
fn ty_infer(&self, span: Span) -> ty::t {
135-
self.tcx.sess.span_bug(span, "found `ty_infer` in unexpected place");
135+
self.tcx.sess.span_err(span, "the type placeholder `_` is not \
136+
allowed within types on item signatures.");
137+
ty::mk_err()
136138
}
137139
}
138140

branches/auto/src/libstd/option.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,10 @@ 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, f: |v: T| -> Option<T>) {
298+
pub fn while_some(self, blk: |v: T| -> Option<T>) {
299299
let mut opt = self;
300-
loop {
301-
match opt {
302-
Some(x) => opt = f(x),
303-
None => break
304-
}
300+
while opt.is_some() {
301+
opt = blk(opt.unwrap());
305302
}
306303
}
307304

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

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -91,47 +91,8 @@ 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)));
9495
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-
}
13596
}
13697
}
13798

@@ -737,25 +698,17 @@ mod test {
737698
use io::MemWriter;
738699
use str;
739700

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-
746701
#[test]
747702
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+
748709
t!("test", "test");
749710
t!("_ZN4testE", "test");
750711
t!("_ZN4test", "_ZN4test");
751712
t!("_ZN4test1a2bcE", "test::a::bc");
752713
}
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-
}
761714
}

branches/auto/src/libsyntax/ast.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,7 @@ pub enum Ty_ {
830830
TyPath(Path, Option<OptVec<TyParamBound>>, NodeId), // for #7264; see above
831831
TyTypeof(@Expr),
832832
// TyInfer means the type should be inferred instead of it having been
833-
// specified. This should only appear at the "top level" of a type and not
834-
// nested in one.
833+
// specified. This can appear anywhere in a type.
835834
TyInfer,
836835
}
837836

branches/auto/src/libsyntax/diagnostic.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ 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";
2022
// maximum number of lines we will print for each error; arbitrary.
2123
static MAX_LINES: uint = 6u;
2224

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

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-
3937
// a span-handler is like a handler but also
4038
// accepts span information for source-location
4139
// reporting.
@@ -63,8 +61,7 @@ impl SpanHandler {
6361
self.handler.custom_emit(&*self.cm, sp, msg, Note);
6462
}
6563
pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
66-
self.handler.emit(Some((&*self.cm, sp)), msg, Bug);
67-
fail!(ExplicitBug);
64+
self.span_fatal(sp, ice_msg(msg));
6865
}
6966
pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
7067
self.span_bug(sp, ~"unimplemented " + msg);
@@ -119,8 +116,7 @@ impl Handler {
119116
self.emit.borrow_mut().get().emit(None, msg, Note);
120117
}
121118
pub fn bug(&self, msg: &str) -> ! {
122-
self.emit.borrow_mut().get().emit(None, msg, Bug);
123-
fail!(ExplicitBug);
119+
self.fatal(ice_msg(msg));
124120
}
125121
pub fn unimpl(&self, msg: &str) -> ! {
126122
self.bug(~"unimplemented " + msg);
@@ -137,6 +133,11 @@ impl Handler {
137133
}
138134
}
139135
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+
140141
pub fn mk_span_handler(handler: @Handler, cm: @codemap::CodeMap)
141142
-> @SpanHandler {
142143
@SpanHandler {
@@ -158,7 +159,6 @@ pub fn mk_handler(e: ~Emitter) -> @Handler {
158159

159160
#[deriving(Eq)]
160161
pub enum Level {
161-
Bug,
162162
Fatal,
163163
Error,
164164
Warning,
@@ -170,7 +170,6 @@ impl fmt::Show for Level {
170170
use std::fmt::Show;
171171

172172
match *self {
173-
Bug => "error: internal compiler error".fmt(f),
174173
Fatal | Error => "error".fmt(f),
175174
Warning => "warning".fmt(f),
176175
Note => "note".fmt(f),
@@ -181,7 +180,7 @@ impl fmt::Show for Level {
181180
impl Level {
182181
fn color(self) -> term::color::Color {
183182
match self {
184-
Bug | Fatal | Error => term::color::BRIGHT_RED,
183+
Fatal | Error => term::color::BRIGHT_RED,
185184
Warning => term::color::BRIGHT_YELLOW,
186185
Note => term::color::BRIGHT_GREEN
187186
}

branches/auto/src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,9 @@ impl Parser {
12741274
bounds
12751275
} = self.parse_path(LifetimeAndTypesAndBounds);
12761276
TyPath(path, bounds, ast::DUMMY_NODE_ID)
1277+
} else if self.eat(&token::UNDERSCORE) {
1278+
// TYPE TO BE INFERRED
1279+
TyInfer
12771280
} else {
12781281
let msg = format!("expected type, found token {:?}", self.token);
12791282
self.fatal(msg);

0 commit comments

Comments
 (0)