Skip to content

Commit 0c56af9

Browse files
committed
---
yaml --- r: 16298 b: refs/heads/try c: a760958 h: refs/heads/master v: v3
1 parent 46dcf7e commit 0c56af9

32 files changed

+253
-136
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: ee8c762bdebb9800e768762e8f7d36a44b65f167
5+
refs/heads/try: a760958b52d3580ffba4d93f7c4732876893fc2a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/Makefile.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,9 @@ else
421421
TSREQS := \
422422
$(foreach target,$(CFG_TARGET_TRIPLES), \
423423
$(SREQ3_T_$(target)_H_$(CFG_HOST_TRIPLE)))
424-
FUZZ := $(HBIN3_H_$(CFG_HOST_TRIPLE))/fuzzer$(X)
425-
CARGO := $(HBIN3_H_$(CFG_HOST_TRIPLE))/cargo$(X)
426-
RUSTDOC := $(HBIN3_H_$(CFG_HOST_TRIPLE))/rustdoc$(X)
424+
FUZZ := $(HBIN2_H_$(CFG_HOST_TRIPLE))/fuzzer$(X)
425+
CARGO := $(HBIN2_H_$(CFG_HOST_TRIPLE))/cargo$(X)
426+
RUSTDOC := $(HBIN2_H_$(CFG_HOST_TRIPLE))/rustdoc$(X)
427427

428428
all: rustc $(GENERATED) docs $(FUZZ) $(CARGO) $(RUSTDOC)
429429

branches/try/src/libcore/cmp.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[doc="Interfaces used for comparison."]
2+
3+
iface ord {
4+
fn lt(&&other: self) -> bool;
5+
}
6+
7+
iface eq {
8+
fn eq(&&other: self) -> bool;
9+
}
10+

branches/try/src/libcore/core.rc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export comm, task, future;
4343
export extfmt;
4444
export tuple;
4545
export to_str;
46+
export swappable;
4647
export dvec, dvec_iter;
48+
export cmp;
4749

4850
// NDM seems to be necessary for resolve to work
4951
export option_iter;
@@ -152,6 +154,7 @@ mod tuple;
152154

153155
// Ubiquitous-utility-type modules
154156

157+
mod cmp;
155158
mod either;
156159
mod iter;
157160
mod logging;
@@ -163,6 +166,7 @@ mod option_iter {
163166
}
164167
mod result;
165168
mod to_str;
169+
mod swappable;
166170
mod dvec;
167171
#[path="iter-trait"]
168172
mod dvec_iter {

branches/try/src/libcore/int-template.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import T = inst::T;
2+
import cmp::{eq, ord};
23

34
export min_value, max_value;
45
export min, max;
@@ -10,6 +11,7 @@ export range;
1011
export compl;
1112
export abs;
1213
export parse_buf, from_str, to_str, to_str_bytes, str;
14+
export ord, eq;
1315

1416
const min_value: T = -1 as T << (inst::bits - 1 as T);
1517
const max_value: T = min_value - 1 as T;
@@ -108,6 +110,18 @@ fn to_str_bytes<U>(n: T, radix: uint, f: fn([u8]/&) -> U) -> U {
108110
#[doc = "Convert to a string"]
109111
fn str(i: T) -> str { ret to_str(i, 10u); }
110112

113+
impl ord of ord for T {
114+
fn lt(&&other: T) -> bool {
115+
ret self < other;
116+
}
117+
}
118+
119+
impl eq of eq for T {
120+
fn eq(&&other: T) -> bool {
121+
ret self == other;
122+
}
123+
}
124+
111125

112126
// FIXME: Has alignment issues on windows and 32-bit linux
113127
#[test]

branches/try/src/libcore/swappable.rs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
export swappable;
2+
export unwrap;
3+
export methods;
4+
5+
#[doc = "
6+
A value that may be swapped out temporarily while it is being processed
7+
and then replaced. Swappables are most useful when working with unique
8+
values, which often cannot be mutated unless they are stored in the local
9+
stack frame to ensure memory safety.
10+
11+
The type guarantees the invariant that the value is always \"swapped in\"
12+
except during the execution of the `swap()` and `with()` methods.
13+
"]
14+
type swappable<A> = {
15+
mut o_t: option<A>
16+
};
17+
18+
#[doc = "Create a swappable swapped in with a given initial value"]
19+
fn swappable<A>(+t: A) -> swappable<A> {
20+
{mut o_t: some(t)}
21+
}
22+
23+
#[doc = "Consumes a swappable and returns its contents without copying"]
24+
fn unwrap<A>(-s: swappable<A>) -> A {
25+
let {o_t: o_t} <- s;
26+
option::unwrap(o_t)
27+
}
28+
29+
impl methods<A> for swappable<A> {
30+
#[doc = "
31+
Overwrites the contents of the swappable
32+
"]
33+
fn set(+a: A) {
34+
self.o_t <- some(a);
35+
}
36+
37+
#[doc = "
38+
Invokes `f()` with the current value but replaces the
39+
current value when complete. Returns the result of `f()`.
40+
41+
Attempts to read or access the receiver while `f()` is executing
42+
will fail dynamically.
43+
"]
44+
fn with<B>(f: fn(A) -> B) -> B {
45+
let mut o_u = none;
46+
self.swap { |t| o_u <- some(f(t)); t }
47+
option::unwrap(o_u)
48+
}
49+
50+
#[doc = "
51+
Invokes `f()` with the current value and then replaces the
52+
current value with the result of `f()`.
53+
54+
Attempts to read or access the receiver while `f()` is executing
55+
will fail dynamically.
56+
"]
57+
fn swap(f: fn(-A) -> A) {
58+
alt self.o_t {
59+
none { fail "no value present---already swapped?"; }
60+
some(_) {}
61+
}
62+
63+
let mut o_t = none;
64+
o_t <-> self.o_t;
65+
self.o_t <- some(f(option::unwrap(o_t)));
66+
}
67+
68+
#[doc = "True if there is a value present in this swappable"]
69+
fn is_present() -> bool {
70+
alt self.o_t {
71+
none {false}
72+
some(_) {true}
73+
}
74+
}
75+
76+
#[doc = "
77+
Removes the value from the swappable. Any further attempts
78+
to use the swapabble without first invoking `set()` will fail.
79+
"]
80+
fn take() -> A {
81+
alt self.o_t {
82+
none { fail "swapped out"; }
83+
some(_) {}
84+
}
85+
86+
let mut o_t = none;
87+
option::unwrap(o_t)
88+
}
89+
}
90+
91+
impl methods<A:copy> for swappable<A> {
92+
#[doc = "
93+
Copies out the contents of the swappable
94+
"]
95+
fn get() -> A {
96+
self.o_t.get()
97+
}
98+
}

branches/try/src/libcore/uint-template.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import T = inst::T;
2+
import cmp::{eq, ord};
23

34
export min_value, max_value;
45
export min, max;
@@ -10,6 +11,7 @@ export range;
1011
export compl;
1112
export to_str, to_str_bytes;
1213
export from_str, from_str_radix, str, parse_buf;
14+
export ord, eq;
1315

1416
const min_value: T = 0 as T;
1517
const max_value: T = 0 as T - 1 as T;
@@ -49,6 +51,18 @@ pure fn compl(i: T) -> T {
4951
max_value ^ i
5052
}
5153

54+
impl ord of ord for T {
55+
fn lt(&&other: T) -> bool {
56+
ret self < other;
57+
}
58+
}
59+
60+
impl eq of eq for T {
61+
fn eq(&&other: T) -> bool {
62+
ret self == other;
63+
}
64+
}
65+
5266
#[doc = "
5367
Parse a buffer of bytes
5468

branches/try/src/libstd/sort.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#[doc = "Sorting methods"];
22
import vec::len;
3+
import int::{eq, ord};
34

45
export le;
56
export merge_sort;
@@ -141,7 +142,6 @@ fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
141142
qsort3::<T>(compare_func_lt, compare_func_eq, arr, i, right);
142143
}
143144

144-
// FIXME: This should take lt and eq types (#2348)
145145
#[doc = "
146146
Fancy quicksort. Sorts a mut vector in place.
147147
@@ -152,22 +152,17 @@ According to these slides this is the algorithm of choice for
152152
153153
This is an unstable sort.
154154
"]
155-
fn quick_sort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
156-
arr: [mut T]) {
155+
fn quick_sort3<T: copy ord eq>(arr: [mut T]) {
157156
if len::<T>(arr) == 0u { ret; }
158-
qsort3::<T>(compare_func_lt, compare_func_eq, arr, 0,
157+
qsort3::<T>({ |x, y| x.lt(y) }, { |x, y| x.eq(y) }, arr, 0,
159158
(len::<T>(arr) as int) - 1);
160159
}
161160

162161
#[cfg(test)]
163162
mod test_qsort3 {
164163
fn check_sort(v1: [mut int], v2: [mut int]) {
165164
let len = vec::len::<int>(v1);
166-
fn lt(&&a: int, &&b: int) -> bool { ret a < b; }
167-
fn equal(&&a: int, &&b: int) -> bool { ret a == b; }
168-
let f1 = lt;
169-
let f2 = equal;
170-
quick_sort3::<int>(f1, f2, v1);
165+
quick_sort3::<int>(v1);
171166
let mut i = 0u;
172167
while i < len {
173168
log(debug, v2[i]);

branches/try/src/libsyntax/diagnostic.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,14 @@ impl codemap_handler of handler for handler_t {
8686
}
8787
fn has_errors() -> bool { self.err_count > 0u }
8888
fn abort_if_errors() {
89-
if self.err_count > 0u {
90-
let s = #fmt["aborting due to %u previous errors",
91-
self.err_count];
92-
self.fatal(s);
89+
let s;
90+
alt self.err_count {
91+
0u { ret; }
92+
1u { s = "aborting due to previous error"; }
93+
_ { s = #fmt["aborting due to %u previous errors",
94+
self.err_count]; }
9395
}
96+
self.fatal(s);
9497
}
9598
fn warn(msg: str) {
9699
self.emit(none, msg, warning);

branches/try/src/rustc/back/link.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ fn link_binary(sess: session,
637637
// and binutils 2.22+ won't add them automatically
638638
if sess.targ_cfg.os == session::os_linux {
639639
cc_args += ["-lrt", "-ldl"];
640+
641+
// LLVM implements the `frem` instruction as a call to `fmod`,
642+
// which lives in libm. Similar to above, on some linuxes we
643+
// have to be explicit about linking to it. See #2510
644+
cc_args += ["-lm"];
640645
}
641646

642647
if sess.targ_cfg.os == session::os_freebsd {

branches/try/src/rustc/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
194194
bind middle::check_loop::check_crate(ty_cx, crate));
195195
time(time_passes, "alt checking",
196196
bind middle::check_alt::check_crate(ty_cx, crate));
197-
let (last_use_map, spill_map) =
197+
let last_use_map =
198198
time(time_passes, "liveness checking",
199199
bind middle::liveness::check_crate(ty_cx, method_map, crate));
200200
time(time_passes, "typestate checking",
@@ -216,7 +216,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
216216
let maps = {mutbl_map: mutbl_map, root_map: root_map,
217217
copy_map: copy_map, last_use_map: last_use_map,
218218
impl_map: impl_map, method_map: method_map,
219-
vtable_map: vtable_map, spill_map: spill_map};
219+
vtable_map: vtable_map};
220220

221221
let (llmod, link_meta) =
222222
time(time_passes, "translation",

branches/try/src/rustc/driver/rustc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import std::map::hashmap;
1515
import getopts::{opt_present};
1616
import rustc::driver::driver::*;
1717
import syntax::codemap;
18-
import rustc::driver::{diagnostic, session};
18+
import syntax::diagnostic;
19+
import rustc::driver::session;
1920
import rustc::middle::lint;
2021
import io::reader_util;
2122

branches/try/src/rustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import syntax::{ast, ast_util};
77
import syntax::attr;
88
import middle::ty;
99
import syntax::ast_map;
10-
import common::*;
1110
import tydecode::{parse_ty_data, parse_def_id, parse_bounds_data,
1211
parse_ident};
1312
import syntax::print::pprust;
1413
import cmd=cstore::crate_metadata;
1514
import util::ppaux::ty_to_str;
1615
import ebml::deserializer;
1716
import syntax::diagnostic::span_handler;
17+
import common::*;
1818

1919
export class_dtor;
2020
export get_class_fields;

branches/try/src/rustc/middle/astencode.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ type maps = {
5757
impl_map: middle::resolve::impl_map,
5858
method_map: middle::typeck::method_map,
5959
vtable_map: middle::typeck::vtable_map,
60-
spill_map: middle::liveness::spill_map
6160
};
6261

6362
type decode_ctxt = @{
@@ -839,12 +838,6 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
839838
}
840839
}
841840

842-
option::iter(maps.spill_map.find(id)) {|_m|
843-
ebml_w.tag(c::tag_table_spill) {||
844-
ebml_w.id(id);
845-
}
846-
}
847-
848841
option::iter(maps.last_use_map.find(id)) {|m|
849842
ebml_w.tag(c::tag_table_last_use) {||
850843
ebml_w.id(id);
@@ -953,8 +946,6 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
953946
dcx.maps.mutbl_map.insert(id, ());
954947
} else if tag == (c::tag_table_copy as uint) {
955948
dcx.maps.copy_map.insert(id, ());
956-
} else if tag == (c::tag_table_spill as uint) {
957-
dcx.maps.spill_map.insert(id, ());
958949
} else {
959950
let val_doc = entry_doc[c::tag_table_val];
960951
let val_dsr = ebml::ebml_deserializer(val_doc);

0 commit comments

Comments
 (0)