Skip to content

Commit b67d90f

Browse files
committed
---
yaml --- r: 39222 b: refs/heads/incoming c: 4ab1c88 h: refs/heads/master v: v3
1 parent 2c36f9a commit b67d90f

File tree

8 files changed

+83
-87
lines changed

8 files changed

+83
-87
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: e23ea24aed95885c8bc59de49c616f60fa5053d1
9+
refs/heads/incoming: 4ab1c8805aee4b6a4254fd90695371a06cbcd301
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/f32.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ impl f32 : cmp::Ord {
163163
}
164164

165165
impl f32: num::Num {
166-
pure fn add(other: &f32) -> f32 { return self + *other; }
167-
pure fn sub(other: &f32) -> f32 { return self - *other; }
168-
pure fn mul(other: &f32) -> f32 { return self * *other; }
169-
pure fn div(other: &f32) -> f32 { return self / *other; }
170-
pure fn modulo(other: &f32) -> f32 { return self % *other; }
171-
pure fn neg() -> f32 { return -self; }
172-
173-
pure fn to_int() -> int { return self as int; }
166+
pure fn add(&self, other: &f32) -> f32 { return *self + *other; }
167+
pure fn sub(&self, other: &f32) -> f32 { return *self - *other; }
168+
pure fn mul(&self, other: &f32) -> f32 { return *self * *other; }
169+
pure fn div(&self, other: &f32) -> f32 { return *self / *other; }
170+
pure fn modulo(&self, other: &f32) -> f32 { return *self % *other; }
171+
pure fn neg(&self) -> f32 { return -*self; }
172+
173+
pure fn to_int(&self) -> int { return *self as int; }
174174
static pure fn from_int(n: int) -> f32 { return n as f32; }
175175
}
176176

branches/incoming/src/libcore/f64.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ impl f64 : cmp::Ord {
182182
}
183183

184184
impl f64: num::Num {
185-
pure fn add(other: &f64) -> f64 { return self + *other; }
186-
pure fn sub(other: &f64) -> f64 { return self - *other; }
187-
pure fn mul(other: &f64) -> f64 { return self * *other; }
188-
pure fn div(other: &f64) -> f64 { return self / *other; }
189-
pure fn modulo(other: &f64) -> f64 { return self % *other; }
190-
pure fn neg() -> f64 { return -self; }
191-
192-
pure fn to_int() -> int { return self as int; }
185+
pure fn add(&self, other: &f64) -> f64 { return *self + *other; }
186+
pure fn sub(&self, other: &f64) -> f64 { return *self - *other; }
187+
pure fn mul(&self, other: &f64) -> f64 { return *self * *other; }
188+
pure fn div(&self, other: &f64) -> f64 { return *self / *other; }
189+
pure fn modulo(&self, other: &f64) -> f64 { return *self % *other; }
190+
pure fn neg(&self) -> f64 { return -*self; }
191+
192+
pure fn to_int(&self) -> int { return *self as int; }
193193
static pure fn from_int(n: int) -> f64 { return n as f64; }
194194
}
195195

branches/incoming/src/libcore/float.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,22 +425,22 @@ impl float : Ord {
425425

426426
impl float: num::Num {
427427
#[inline(always)]
428-
pub pure fn add(other: &float) -> float { return self + *other; }
428+
pub pure fn add(&self, other: &float) -> float { return *self + *other; }
429429
#[inline(always)]
430-
pub pure fn sub(other: &float) -> float { return self - *other; }
430+
pub pure fn sub(&self, other: &float) -> float { return *self - *other; }
431431
#[inline(always)]
432-
pub pure fn mul(other: &float) -> float { return self * *other; }
432+
pub pure fn mul(&self, other: &float) -> float { return *self * *other; }
433433
#[inline(always)]
434-
pub pure fn div(other: &float) -> float { return self / *other; }
434+
pub pure fn div(&self, other: &float) -> float { return *self / *other; }
435435
#[inline(always)]
436-
pure fn modulo(other: &float) -> float { return self % *other; }
436+
pure fn modulo(&self, other: &float) -> float { return *self % *other; }
437437
#[inline(always)]
438-
pure fn neg() -> float { return -self; }
438+
pure fn neg(&self) -> float { return -*self; }
439439

440440
#[inline(always)]
441-
pure fn to_int() -> int { return self as int; }
441+
pure fn to_int(&self) -> int { return *self as int; }
442442
#[inline(always)]
443-
static pure fn from_int(n: int) -> float { return n as float; }
443+
static pure fn from_int(&self, n: int) -> float { return n as float; }
444444
}
445445

446446
#[test]

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ impl T : Eq {
7979
}
8080

8181
impl T: num::Num {
82-
pure fn add(other: &T) -> T { return self + *other; }
83-
pure fn sub(other: &T) -> T { return self - *other; }
84-
pure fn mul(other: &T) -> T { return self * *other; }
85-
pure fn div(other: &T) -> T { return self / *other; }
86-
pure fn modulo(other: &T) -> T { return self % *other; }
87-
pure fn neg() -> T { return -self; }
88-
89-
pure fn to_int() -> int { return self as int; }
82+
pure fn add(&self, other: &T) -> T { return *self + *other; }
83+
pure fn sub(&self, other: &T) -> T { return *self - *other; }
84+
pure fn mul(&self, other: &T) -> T { return *self * *other; }
85+
pure fn div(&self, other: &T) -> T { return *self / *other; }
86+
pure fn modulo(&self, other: &T) -> T { return *self % *other; }
87+
pure fn neg(&self) -> T { return -*self; }
88+
89+
pure fn to_int(&self) -> int { return *self as int; }
9090
static pure fn from_int(n: int) -> T { return n as T; }
9191
}
9292

branches/incoming/src/libcore/num.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
1313
pub trait Num {
1414
// FIXME: Trait composition. (#2616)
15-
pure fn add(other: &self) -> self;
16-
pure fn sub(other: &self) -> self;
17-
pure fn mul(other: &self) -> self;
18-
pure fn div(other: &self) -> self;
19-
pure fn modulo(other: &self) -> self;
20-
pure fn neg() -> self;
15+
pure fn add(&self, other: &self) -> self;
16+
pure fn sub(&self, other: &self) -> self;
17+
pure fn mul(&self, other: &self) -> self;
18+
pure fn div(&self, other: &self) -> self;
19+
pure fn modulo(&self, other: &self) -> self;
20+
pure fn neg(&self) -> self;
2121

22-
pure fn to_int() -> int;
22+
pure fn to_int(&self) -> int;
2323
static pure fn from_int(n: int) -> self;
2424
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ impl T : Eq {
7373
}
7474

7575
impl T: num::Num {
76-
pure fn add(other: &T) -> T { return self + *other; }
77-
pure fn sub(other: &T) -> T { return self - *other; }
78-
pure fn mul(other: &T) -> T { return self * *other; }
79-
pure fn div(other: &T) -> T { return self / *other; }
80-
pure fn modulo(other: &T) -> T { return self % *other; }
81-
pure fn neg() -> T { return -self; }
82-
83-
pure fn to_int() -> int { return self as int; }
76+
pure fn add(&self, other: &T) -> T { return *self + *other; }
77+
pure fn sub(&self, other: &T) -> T { return *self - *other; }
78+
pure fn mul(&self, other: &T) -> T { return *self * *other; }
79+
pure fn div(&self, other: &T) -> T { return *self / *other; }
80+
pure fn modulo(&self, other: &T) -> T { return *self % *other; }
81+
pure fn neg(&self) -> T { return -*self; }
82+
83+
pure fn to_int(&self) -> int { return *self as int; }
8484
static pure fn from_int(n: int) -> T { return n as T; }
8585
}
8686

branches/incoming/src/libsyntax/codemap.rs

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,25 @@ impl BytePos: cmp::Ord {
5959
pure fn gt(&self, other: &BytePos) -> bool { **self > **other }
6060
}
6161

62-
impl BytePos: Num {
63-
pure fn add(other: &BytePos) -> BytePos {
64-
BytePos(*self + **other)
62+
#[cfg(stage0)]
63+
impl BytePos: Add<BytePos, BytePos> {
64+
pure fn add(rhs: &BytePos) -> BytePos {
65+
BytePos(*self + **rhs)
6566
}
66-
pure fn sub(other: &BytePos) -> BytePos {
67-
BytePos(*self - **other)
68-
}
69-
pure fn mul(other: &BytePos) -> BytePos {
70-
BytePos(*self * (**other))
71-
}
72-
pure fn div(other: &BytePos) -> BytePos {
73-
BytePos(*self / **other)
74-
}
75-
pure fn modulo(other: &BytePos) -> BytePos {
76-
BytePos(*self % **other)
67+
}
68+
69+
#[cfg(stage1)]
70+
#[cfg(stage2)]
71+
impl BytePos: Add<BytePos, BytePos> {
72+
pure fn add(&self, rhs: &BytePos) -> BytePos {
73+
BytePos(**self + **rhs)
7774
}
78-
pure fn neg() -> BytePos {
79-
BytePos(-*self)
75+
}
76+
77+
impl BytePos: Sub<BytePos, BytePos> {
78+
pure fn sub(&self, rhs: &BytePos) -> BytePos {
79+
BytePos(**self - **rhs)
8080
}
81-
pure fn to_int() -> int { *self as int }
82-
static pure fn from_int(+n: int) -> BytePos { BytePos(n as uint) }
8381
}
8482

8583
impl BytePos: to_bytes::IterBytes {
@@ -105,32 +103,30 @@ impl CharPos: cmp::Ord {
105103
pure fn gt(&self, other: &CharPos) -> bool { **self > **other }
106104
}
107105

108-
impl CharPos: Num {
109-
pure fn add(other: &CharPos) -> CharPos {
110-
CharPos(*self + **other)
111-
}
112-
pure fn sub(other: &CharPos) -> CharPos {
113-
CharPos(*self - **other)
114-
}
115-
pure fn mul(other: &CharPos) -> CharPos {
116-
CharPos(*self * (**other))
117-
}
118-
pure fn div(other: &CharPos) -> CharPos {
119-
CharPos(*self / **other)
106+
impl CharPos: to_bytes::IterBytes {
107+
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
108+
(**self).iter_bytes(lsb0, f)
120109
}
121-
pure fn modulo(other: &CharPos) -> CharPos {
122-
CharPos(*self % **other)
110+
}
111+
112+
#[cfg(stage0)]
113+
impl CharPos: Add<CharPos, CharPos> {
114+
pure fn add(rhs: &CharPos) -> CharPos {
115+
CharPos(*self + **rhs)
123116
}
124-
pure fn neg() -> CharPos {
125-
CharPos(-*self)
117+
}
118+
119+
#[cfg(stage1)]
120+
#[cfg(stage2)]
121+
impl CharPos: Add<CharPos, CharPos> {
122+
pure fn add(&self, rhs: &CharPos) -> CharPos {
123+
CharPos(**self + **rhs)
126124
}
127-
pure fn to_int() -> int { *self as int }
128-
static pure fn from_int(+n: int) -> CharPos { CharPos(n as uint) }
129125
}
130126

131-
impl CharPos: to_bytes::IterBytes {
132-
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
133-
(**self).iter_bytes(lsb0, f)
127+
impl CharPos: Sub<CharPos, CharPos> {
128+
pure fn sub(&self, rhs: &CharPos) -> CharPos {
129+
CharPos(**self - **rhs)
134130
}
135131
}
136132

0 commit comments

Comments
 (0)