Skip to content

Commit 9117dcb

Browse files
committed
rustc: De-mode all overloaded operators
1 parent 6b670c3 commit 9117dcb

Some content is hidden

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

100 files changed

+3967
-247
lines changed

src/cargo/cargo.rs

+33
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type package = {
2626
versions: ~[(~str, ~str)]
2727
};
2828

29+
#[cfg(stage0)]
2930
impl package : cmp::Ord {
3031
pure fn lt(&&other: package) -> bool {
3132
if self.name.lt(other.name) { return true; }
@@ -47,6 +48,29 @@ impl package : cmp::Ord {
4748
pure fn ge(&&other: package) -> bool { !self.lt(other) }
4849
pure fn gt(&&other: package) -> bool { other.lt(self) }
4950
}
51+
#[cfg(stage1)]
52+
#[cfg(stage2)]
53+
impl package : cmp::Ord {
54+
pure fn lt(other: &package) -> bool {
55+
if self.name.lt(&(*other).name) { return true; }
56+
if (*other).name.lt(&self.name) { return false; }
57+
if self.uuid.lt(&(*other).uuid) { return true; }
58+
if (*other).uuid.lt(&self.uuid) { return false; }
59+
if self.url.lt(&(*other).url) { return true; }
60+
if (*other).url.lt(&self.url) { return false; }
61+
if self.method.lt(&(*other).method) { return true; }
62+
if (*other).method.lt(&self.method) { return false; }
63+
if self.description.lt(&(*other).description) { return true; }
64+
if (*other).description.lt(&self.description) { return false; }
65+
if self.tags.lt(&(*other).tags) { return true; }
66+
if (*other).tags.lt(&self.tags) { return false; }
67+
if self.versions.lt(&(*other).versions) { return true; }
68+
return false;
69+
}
70+
pure fn le(other: &package) -> bool { !(*other).lt(&self) }
71+
pure fn ge(other: &package) -> bool { !self.lt(other) }
72+
pure fn gt(other: &package) -> bool { (*other).lt(&self) }
73+
}
5074

5175
type local_package = {
5276
name: ~str,
@@ -97,12 +121,21 @@ type options = {
97121

98122
enum mode { system_mode, user_mode, local_mode }
99123

124+
#[cfg(stage0)]
100125
impl mode : cmp::Eq {
101126
pure fn eq(&&other: mode) -> bool {
102127
(self as uint) == (other as uint)
103128
}
104129
pure fn ne(&&other: mode) -> bool { !self.eq(other) }
105130
}
131+
#[cfg(stage1)]
132+
#[cfg(stage2)]
133+
impl mode : cmp::Eq {
134+
pure fn eq(other: &mode) -> bool {
135+
(self as uint) == ((*other) as uint)
136+
}
137+
pure fn ne(other: &mode) -> bool { !self.eq(other) }
138+
}
106139

107140
fn opts() -> ~[getopts::Opt] {
108141
~[optflag(~"g"), optflag(~"G"), optflag(~"test"),

src/compiletest/common.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, }
22

3+
#[cfg(stage0)]
34
impl mode : cmp::Eq {
45
pure fn eq(&&other: mode) -> bool {
56
other as int == self as int
67
}
78
pure fn ne(&&other: mode) -> bool { !self.eq(other) }
89
}
10+
#[cfg(stage1)]
11+
#[cfg(stage2)]
12+
impl mode : cmp::Eq {
13+
pure fn eq(other: &mode) -> bool {
14+
(*other) as int == self as int
15+
}
16+
pure fn ne(other: &mode) -> bool { !self.eq(other) }
17+
}
918

1019
type config = {
1120
// The library paths required for running the compiler

src/fuzzer/fuzzer.rs

+9
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ use syntax::diagnostic;
88
enum test_mode { tm_converge, tm_run, }
99
type context = { mode: test_mode }; // + rng
1010

11+
#[cfg(stage0)]
1112
impl test_mode : cmp::Eq {
1213
pure fn eq(&&other: test_mode) -> bool {
1314
(self as uint) == (other as uint)
1415
}
1516
pure fn ne(&&other: test_mode) -> bool { !self.eq(other) }
1617
}
18+
#[cfg(stage1)]
19+
#[cfg(stage2)]
20+
impl test_mode : cmp::Eq {
21+
pure fn eq(other: &test_mode) -> bool {
22+
(self as uint) == ((*other) as uint)
23+
}
24+
pure fn ne(other: &test_mode) -> bool { !self.eq(other) }
25+
}
1726

1827
fn write_file(filename: &Path, content: ~str) {
1928
result::get(

src/libcore/at_vec.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export build_sized, build, build_sized_opt;
88
export map;
99
export from_fn, from_elem;
1010
export raw;
11+
export traits;
1112

1213
/// Code for dealing with @-vectors. This is pretty incomplete, and
1314
/// contains a bunch of duplication from the code for ~-vectors.
@@ -133,13 +134,26 @@ pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
133134
}
134135

135136
#[cfg(notest)]
136-
impl<T: Copy> @[T]: Add<&[const T],@[T]> {
137-
#[inline(always)]
138-
pure fn add(rhs: &[const T]) -> @[T] {
139-
append(self, rhs)
137+
mod traits {
138+
#[cfg(stage0)]
139+
impl<T: Copy> @[T]: Add<&[const T],@[T]> {
140+
#[inline(always)]
141+
pure fn add(rhs: &[const T]) -> @[T] {
142+
append(self, rhs)
143+
}
144+
}
145+
#[cfg(stage1)]
146+
#[cfg(stage2)]
147+
impl<T: Copy> @[T] : Add<&[const T],@[T]> {
148+
#[inline(always)]
149+
pure fn add(rhs: & &[const T]) -> @[T] {
150+
append(self, (*rhs))
151+
}
140152
}
141153
}
142154

155+
#[cfg(test)]
156+
mod traits {}
143157

144158
mod raw {
145159
type VecRepr = vec::raw::VecRepr;

src/libcore/bool.rs

+7
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ fn all_values(blk: fn(v: bool)) {
6969
/// converts truth value to an 8 bit byte
7070
pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
7171

72+
#[cfg(stage0)]
7273
impl bool : cmp::Eq {
7374
pure fn eq(&&other: bool) -> bool { self == other }
7475
pure fn ne(&&other: bool) -> bool { self != other }
7576
}
77+
#[cfg(stage1)]
78+
#[cfg(stage2)]
79+
impl bool : cmp::Eq {
80+
pure fn eq(other: &bool) -> bool { self == (*other) }
81+
pure fn ne(other: &bool) -> bool { self != (*other) }
82+
}
7683

7784
#[test]
7885
fn test_bool_from_str() {

src/libcore/box.rs

+16
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,33 @@ pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
3030
unsafe { ptr::addr_of(*a) == ptr::addr_of(*b) }
3131
}
3232

33+
#[cfg(stage0)]
3334
impl<T:Eq> @const T : Eq {
3435
pure fn eq(&&other: @const T) -> bool { *self == *other }
3536
pure fn ne(&&other: @const T) -> bool { *self != *other }
3637
}
38+
#[cfg(stage1)]
39+
#[cfg(stage2)]
40+
impl<T:Eq> @const T : Eq {
41+
pure fn eq(other: &@const T) -> bool { *self == *(*other) }
42+
pure fn ne(other: &@const T) -> bool { *self != *(*other) }
43+
}
3744

45+
#[cfg(stage0)]
3846
impl<T:Ord> @const T : Ord {
3947
pure fn lt(&&other: @const T) -> bool { *self < *other }
4048
pure fn le(&&other: @const T) -> bool { *self <= *other }
4149
pure fn ge(&&other: @const T) -> bool { *self >= *other }
4250
pure fn gt(&&other: @const T) -> bool { *self > *other }
4351
}
52+
#[cfg(stage1)]
53+
#[cfg(stage2)]
54+
impl<T:Ord> @const T : Ord {
55+
pure fn lt(other: &@const T) -> bool { *self < *(*other) }
56+
pure fn le(other: &@const T) -> bool { *self <= *(*other) }
57+
pure fn ge(other: &@const T) -> bool { *self >= *(*other) }
58+
pure fn gt(other: &@const T) -> bool { *self > *(*other) }
59+
}
4460

4561
#[test]
4662
fn test() {

src/libcore/char.rs

+7
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,17 @@ pure fn cmp(a: char, b: char) -> int {
189189
else { 0 }
190190
}
191191

192+
#[cfg(stage0)]
192193
impl char: Eq {
193194
pure fn eq(&&other: char) -> bool { self == other }
194195
pure fn ne(&&other: char) -> bool { self != other }
195196
}
197+
#[cfg(stage1)]
198+
#[cfg(stage2)]
199+
impl char : Eq {
200+
pure fn eq(other: &char) -> bool { self == (*other) }
201+
pure fn ne(other: &char) -> bool { self != (*other) }
202+
}
196203

197204
#[test]
198205
fn test_is_lowercase() {

0 commit comments

Comments
 (0)