Skip to content

Commit a44dcf3

Browse files
committed
---
yaml --- r: 13276 b: refs/heads/master c: c6e16c5 h: refs/heads/master v: v3
1 parent b149372 commit a44dcf3

File tree

20 files changed

+95
-228
lines changed

20 files changed

+95
-228
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d64ff983110fed10a7a3351ad156091cfaf3203b
2+
refs/heads/master: c6e16c5668a86245259a4f542a62199b2023b89b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/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+

trunk/src/libcore/core.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export comm, task, future;
4343
export extfmt;
4444
export tuple;
4545
export to_str;
46-
export swappable;
4746
export dvec, dvec_iter;
47+
export cmp;
4848

4949
// NDM seems to be necessary for resolve to work
5050
export option_iter;
@@ -153,6 +153,7 @@ mod tuple;
153153

154154
// Ubiquitous-utility-type modules
155155

156+
mod cmp;
156157
mod either;
157158
mod iter;
158159
mod logging;
@@ -164,7 +165,6 @@ mod option_iter {
164165
}
165166
mod result;
166167
mod to_str;
167-
mod swappable;
168168
mod dvec;
169169
#[path="iter-trait"]
170170
mod dvec_iter {

trunk/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]

trunk/src/libcore/swappable.rs

Lines changed: 0 additions & 98 deletions
This file was deleted.

trunk/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

trunk/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]);

trunk/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",

trunk/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

trunk/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;

trunk/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)