Skip to content

Commit 8987ec2

Browse files
committed
---
yaml --- r: 10704 b: refs/heads/snap-stage3 c: 7e6cbf7 h: refs/heads/master v: v3
1 parent 248f6bd commit 8987ec2

File tree

8 files changed

+93
-92
lines changed

8 files changed

+93
-92
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 43a48ca5bba2698e253d6229139328d353276ee8
4+
refs/heads/snap-stage3: 7e6cbf7431671ecdfe60f7ec9fdd5af65248a7a2
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/libcore/core.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ import option_iter::extensions;
1212
import ptr::extensions;
1313
import rand::extensions;
1414
import result::extensions;
15-
import int::extensions::*;
16-
import i8::extensions::*;
17-
import i16::extensions::*;
18-
import i32::extensions::*;
19-
import i64::extensions::*;
20-
import uint::extensions::*;
21-
import u8::extensions::*;
22-
import u16::extensions::*;
23-
import u32::extensions::*;
24-
import u64::extensions::*;
25-
import float::extensions::*;
26-
import f32::extensions::*;
27-
import f64::extensions::*;
15+
import int::num;
16+
import i8::num;
17+
import i16::num;
18+
import i32::num;
19+
import i64::num;
20+
import uint::num;
21+
import u8::num;
22+
import u16::num;
23+
import u32::num;
24+
import u64::num;
25+
import float::num;
26+
import f32::num;
27+
import f64::num;
2828

2929
export path, option, some, none, unreachable;
3030
export extensions;

branches/snap-stage3/src/libcore/f32.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
import cmath::c_float::*;
66
import cmath::c_float_targ_consts::*;
7-
import num::num;
87

9-
export add, sub, mul, div, rem, lt, le, gt, eq, eq, ne;
8+
export add, sub, mul, div, rem, lt, le, gt, eq, ne;
109
export is_positive, is_negative, is_nonpositive, is_nonnegative;
1110
export is_zero, is_infinite, is_finite;
1211
export NaN, is_NaN, infinity, neg_infinity;
@@ -18,7 +17,8 @@ export mul_add, fmax, fmin, nextafter, frexp, hypot, ldexp;
1817
export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
1918
export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
2019
export signbit;
21-
export extensions;
20+
21+
export num;
2222

2323
// These are not defined inside consts:: for consistency with
2424
// the integer types
@@ -173,18 +173,16 @@ pure fn log2(n: f32) -> f32 {
173173
ret ln(n) / consts::ln_2;
174174
}
175175

176-
mod extensions {
177-
impl num of num for f32 {
178-
fn add(&&other: f32) -> f32 { ret self + other; }
179-
fn sub(&&other: f32) -> f32 { ret self - other; }
180-
fn mul(&&other: f32) -> f32 { ret self * other; }
181-
fn div(&&other: f32) -> f32 { ret self / other; }
182-
fn modulo(&&other: f32) -> f32 { ret self % other; }
183-
fn neg() -> f32 { ret -self; }
184-
185-
fn to_int() -> int { ret self as int; }
186-
fn from_int(n: int) -> f32 { ret n as f32; }
187-
}
176+
impl num of num::num for f32 {
177+
fn add(&&other: f32) -> f32 { ret self + other; }
178+
fn sub(&&other: f32) -> f32 { ret self - other; }
179+
fn mul(&&other: f32) -> f32 { ret self * other; }
180+
fn div(&&other: f32) -> f32 { ret self / other; }
181+
fn modulo(&&other: f32) -> f32 { ret self % other; }
182+
fn neg() -> f32 { ret -self; }
183+
184+
fn to_int() -> int { ret self as int; }
185+
fn from_int(n: int) -> f32 { ret n as f32; }
188186
}
189187

190188
//

branches/snap-stage3/src/libcore/f64.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
import cmath::c_double::*;
66
import cmath::c_double_targ_consts::*;
7-
import num::num;
87

98
// Even though this module exports everything defined in it,
109
// because it contains re-exports, we also have to explicitly
1110
// export locally defined things. That's a bit annoying.
12-
export add, sub, mul, div, rem, lt, le, gt, eq, eq, ne;
11+
export add, sub, mul, div, rem, lt, le, gt, eq, ne;
1312
export is_positive, is_negative, is_nonpositive, is_nonnegative;
1413
export is_zero, is_infinite, is_finite;
1514
export NaN, is_NaN, infinity, neg_infinity;
@@ -22,7 +21,10 @@ export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
2221
export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
2322
export signbit;
2423
export epsilon;
25-
export extensions;
24+
25+
export j0, j1, jn, y0, y1, yn;
26+
27+
export num;
2628

2729
// These are not defined inside consts:: for consistency with
2830
// the integer types
@@ -196,18 +198,16 @@ pure fn log2(n: f64) -> f64 {
196198
ret ln(n) / consts::ln_2;
197199
}
198200

199-
mod extensions {
200-
impl num of num for f64 {
201-
fn add(&&other: f64) -> f64 { ret self + other; }
202-
fn sub(&&other: f64) -> f64 { ret self - other; }
203-
fn mul(&&other: f64) -> f64 { ret self * other; }
204-
fn div(&&other: f64) -> f64 { ret self / other; }
205-
fn modulo(&&other: f64) -> f64 { ret self % other; }
206-
fn neg() -> f64 { ret -self; }
207-
208-
fn to_int() -> int { ret self as int; }
209-
fn from_int(n: int) -> f64 { ret n as f64; }
210-
}
201+
impl num of num::num for f64 {
202+
fn add(&&other: f64) -> f64 { ret self + other; }
203+
fn sub(&&other: f64) -> f64 { ret self - other; }
204+
fn mul(&&other: f64) -> f64 { ret self * other; }
205+
fn div(&&other: f64) -> f64 { ret self / other; }
206+
fn modulo(&&other: f64) -> f64 { ret self % other; }
207+
fn neg() -> f64 { ret -self; }
208+
209+
fn to_int() -> int { ret self as int; }
210+
fn from_int(n: int) -> f64 { ret n as f64; }
211211
}
212212

213213
//

branches/snap-stage3/src/libcore/float.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// because it contains re-exports, we also have to explicitly
55
// export locally defined things. That's a bit annoying.
66
export to_str_common, to_str_exact, to_str, from_str;
7-
export add, sub, mul, div, rem, lt, le, gt, eq, eq, ne;
7+
export add, sub, mul, div, rem, lt, le, gt, eq, ne;
88
export is_positive, is_negative, is_nonpositive, is_nonnegative;
99
export is_zero, is_infinite, is_finite;
1010
export NaN, is_NaN, infinity, neg_infinity;
@@ -17,7 +17,8 @@ export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
1717
export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
1818
export signbit;
1919
export pow_with_uint;
20-
export extensions;
20+
21+
export num;
2122

2223
// export when m_float == c_double
2324

@@ -26,8 +27,16 @@ export j0, j1, jn, y0, y1, yn;
2627
// PORT this must match in width according to architecture
2728

2829
import m_float = f64;
29-
import f64::*;
30-
import num::num;
30+
31+
import f64::{add, sub, mul, div, rem, lt, le, gt, eq, ne};
32+
import f64::logarithm;
33+
import f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
34+
import f64::{erf, erfc, exp, expm1, exp2, abs_sub};
35+
import f64::{mul_add, fmax, fmin, nextafter, frexp, hypot, ldexp};
36+
import f64::{lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix};
37+
import f64::{modf, pow, round, sinh, tanh, tgamma, trunc};
38+
import f64::signbit;
39+
import f64::{j0, j1, jn, y0, y1, yn};
3140

3241
const NaN: float = 0.0/0.0;
3342

@@ -410,18 +419,16 @@ fn sin(x: float) -> float { f64::sin(x as f64) as float }
410419
fn cos(x: float) -> float { f64::cos(x as f64) as float }
411420
fn tan(x: float) -> float { f64::tan(x as f64) as float }
412421

413-
mod extensions {
414-
impl num of num for float {
415-
fn add(&&other: float) -> float { ret self + other; }
416-
fn sub(&&other: float) -> float { ret self - other; }
417-
fn mul(&&other: float) -> float { ret self * other; }
418-
fn div(&&other: float) -> float { ret self / other; }
419-
fn modulo(&&other: float) -> float { ret self % other; }
420-
fn neg() -> float { ret -self; }
421-
422-
fn to_int() -> int { ret self as int; }
423-
fn from_int(n: int) -> float { ret n as float; }
424-
}
422+
impl num of num::num for float {
423+
fn add(&&other: float) -> float { ret self + other; }
424+
fn sub(&&other: float) -> float { ret self - other; }
425+
fn mul(&&other: float) -> float { ret self * other; }
426+
fn div(&&other: float) -> float { ret self / other; }
427+
fn modulo(&&other: float) -> float { ret self % other; }
428+
fn neg() -> float { ret -self; }
429+
430+
fn to_int() -> int { ret self as int; }
431+
fn from_int(n: int) -> float { ret n as float; }
425432
}
426433

427434
#[test]
@@ -519,7 +526,7 @@ fn test_to_str_inf() {
519526

520527
#[test]
521528
fn test_ifaces() {
522-
fn test<U:num>(ten: U) {
529+
fn test<U:num::num>(ten: U) {
523530
assert (ten.to_int() == 10);
524531

525532
let two = ten.from_int(2);

branches/snap-stage3/src/libcore/int-template.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import T = inst::T;
22
import cmp::{eq, ord};
3-
import num::num;
43

54
export min_value, max_value;
65
export min, max;
@@ -12,7 +11,7 @@ export range;
1211
export compl;
1312
export abs;
1413
export parse_buf, from_str, to_str, to_str_bytes, str;
15-
export ord, eq, extensions;
14+
export num, ord, eq;
1615

1716
const min_value: T = -1 as T << (inst::bits - 1 as T);
1817
const max_value: T = min_value - 1 as T;
@@ -124,18 +123,16 @@ impl eq of eq for T {
124123
}
125124
}
126125

127-
mod extensions {
128-
impl num of num::num for T {
129-
fn add(&&other: T) -> T { ret self + other; }
130-
fn sub(&&other: T) -> T { ret self - other; }
131-
fn mul(&&other: T) -> T { ret self * other; }
132-
fn div(&&other: T) -> T { ret self / other; }
133-
fn modulo(&&other: T) -> T { ret self % other; }
134-
fn neg() -> T { ret -self; }
135-
136-
fn to_int() -> int { ret self as int; }
137-
fn from_int(n: int) -> T { ret n as T; }
138-
}
126+
impl num of num::num for T {
127+
fn add(&&other: T) -> T { ret self + other; }
128+
fn sub(&&other: T) -> T { ret self - other; }
129+
fn mul(&&other: T) -> T { ret self * other; }
130+
fn div(&&other: T) -> T { ret self / other; }
131+
fn modulo(&&other: T) -> T { ret self % other; }
132+
fn neg() -> T { ret -self; }
133+
134+
fn to_int() -> int { ret self as int; }
135+
fn from_int(n: int) -> T { ret n as T; }
139136
}
140137

141138

branches/snap-stage3/src/libcore/uint-template.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import T = inst::T;
22
import cmp::{eq, ord};
3-
import num::num;
43

54
export min_value, max_value;
65
export min, max;
@@ -12,7 +11,7 @@ export range;
1211
export compl;
1312
export to_str, to_str_bytes;
1413
export from_str, from_str_radix, str, parse_buf;
15-
export ord, eq, extensions;
14+
export num, ord, eq;
1615

1716
const min_value: T = 0 as T;
1817
const max_value: T = 0 as T - 1 as T;
@@ -65,18 +64,16 @@ impl eq of eq for T {
6564
}
6665
}
6766

68-
mod extensions {
69-
impl num of num::num for T {
70-
fn add(&&other: T) -> T { ret self + other; }
71-
fn sub(&&other: T) -> T { ret self - other; }
72-
fn mul(&&other: T) -> T { ret self * other; }
73-
fn div(&&other: T) -> T { ret self / other; }
74-
fn modulo(&&other: T) -> T { ret self % other; }
75-
fn neg() -> T { ret -self; }
76-
77-
fn to_int() -> int { ret self as int; }
78-
fn from_int(n: int) -> T { ret n as T; }
79-
}
67+
impl num of num::num for T {
68+
fn add(&&other: T) -> T { ret self + other; }
69+
fn sub(&&other: T) -> T { ret self - other; }
70+
fn mul(&&other: T) -> T { ret self * other; }
71+
fn div(&&other: T) -> T { ret self / other; }
72+
fn modulo(&&other: T) -> T { ret self % other; }
73+
fn neg() -> T { ret -self; }
74+
75+
fn to_int() -> int { ret self as int; }
76+
fn from_int(n: int) -> T { ret n as T; }
8077
}
8178

8279
#[doc = "

branches/snap-stage3/src/test/run-pass/numeric-method-autoexport.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1+
2+
13
// This file is intended to test only that methods are automatically
24
// reachable for each numeric type, for each exported impl, with no imports
35
// necessary. Testing the methods of the impls is done within the source
46
// file for each numeric type.
57
fn main() {
6-
// extensions::num
8+
// num
79
assert 15.add(6) == 21;
810
assert 15i8.add(6i8) == 21i8;
911
assert 15i16.add(6i16) == 21i16;
1012
assert 15i32.add(6i32) == 21i32;
1113
assert 15i64.add(6i64) == 21i64;
1214

13-
// extensions::num
15+
// num
1416
assert 15u.add(6u) == 21u;
1517
assert 15u8.add(6u8) == 21u8;
1618
assert 15u16.add(6u16) == 21u16;
1719
assert 15u32.add(6u32) == 21u32;
1820
assert 15u64.add(6u64) == 21u64;
1921

20-
// extensions::num
22+
// num
2123
assert 10f.to_int() == 10;
2224
assert 10f32.to_int() == 10;
2325
assert 10f64.to_int() == 10;

0 commit comments

Comments
 (0)