Skip to content

Commit 255f6b2

Browse files
committed
---
yaml --- r: 150463 b: refs/heads/try2 c: e63346b h: refs/heads/master i: 150461: 5eeb6e1 150459: 69cb1f1 150455: d9501a8 150447: 34cacdb 150431: 2cf6770 150399: 2cedc1a v: v3
1 parent 2816809 commit 255f6b2

File tree

32 files changed

+398
-486
lines changed

32 files changed

+398
-486
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 129cf09209f457cd79e5c3cdf513fd65e488d29e
8+
refs/heads/try2: e63346b9d8b1a8f38d9a3dbd694cc77b08ffa1e7
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/guide-pointers.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,6 @@ sense, they're simple: just keep whatever ownership the data already has. For
332332
example:
333333

334334
~~~rust
335-
use std::num::sqrt;
336-
337335
struct Point {
338336
x: f32,
339337
y: f32,
@@ -343,7 +341,7 @@ fn compute_distance(p1: &Point, p2: &Point) -> f32 {
343341
let x_d = p1.x - p2.x;
344342
let y_d = p1.y - p2.y;
345343

346-
sqrt(x_d * x_d + y_d * y_d)
344+
(x_d * x_d + y_d * y_d).sqrt()
347345
}
348346

349347
fn main() {

branches/try2/src/doc/rust.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,14 +826,14 @@ Use declarations support a number of convenient shortcuts:
826826
An example of `use` declarations:
827827

828828
~~~~
829-
use std::num::sin;
829+
use std::iter::range_step;
830830
use std::option::{Some, None};
831831
832832
# fn foo<T>(_: T){}
833833
834834
fn main() {
835-
// Equivalent to 'std::num::sin(1.0);'
836-
sin(1.0);
835+
// Equivalent to 'std::iter::range_step(0, 10, 2);'
836+
range_step(0, 10, 2);
837837
838838
// Equivalent to 'foo(~[std::option::Some(1.0), std::option::None]);'
839839
foo(~[Some(1.0), None]);

branches/try2/src/doc/tutorial.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,12 @@ matching in order to bind names to the contents of data types.
504504
505505
~~~~
506506
use std::f64;
507-
use std::num::atan;
508507
fn angle(vector: (f64, f64)) -> f64 {
509508
let pi = f64::consts::PI;
510509
match vector {
511510
(0.0, y) if y < 0.0 => 1.5 * pi,
512511
(0.0, _) => 0.5 * pi,
513-
(x, y) => atan(y / x)
512+
(x, y) => (y / x).atan()
514513
}
515514
}
516515
~~~~
@@ -1430,12 +1429,11 @@ bad, but often copies are expensive. So we’d like to define a function
14301429
that takes the points by pointer. We can use references to do this:
14311430
14321431
~~~
1433-
use std::num::sqrt;
14341432
# struct Point { x: f64, y: f64 }
14351433
fn compute_distance(p1: &Point, p2: &Point) -> f64 {
14361434
let x_d = p1.x - p2.x;
14371435
let y_d = p1.y - p2.y;
1438-
sqrt(x_d * x_d + y_d * y_d)
1436+
(x_d * x_d + y_d * y_d).sqrt()
14391437
}
14401438
~~~
14411439
@@ -2303,7 +2301,7 @@ impl Shape for Circle {
23032301
fn new(area: f64) -> Circle { Circle { radius: (area / PI).sqrt() } }
23042302
}
23052303
impl Shape for Square {
2306-
fn new(area: f64) -> Square { Square { length: (area).sqrt() } }
2304+
fn new(area: f64) -> Square { Square { length: area.sqrt() } }
23072305
}
23082306
23092307
let area = 42.5;

branches/try2/src/libcollections/deque.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub mod bench {
5252
map: &mut M,
5353
bh: &mut BenchHarness) {
5454
// setup
55-
let mut rng = rand::XorShiftRng::new();
55+
let mut rng = rand::weak_rng();
5656

5757
map.clear();
5858
for _ in range(0, n) {
@@ -89,7 +89,7 @@ pub mod bench {
8989
map: &mut M,
9090
bh: &mut BenchHarness) {
9191
// setup
92-
let mut rng = rand::XorShiftRng::new();
92+
let mut rng = rand::weak_rng();
9393
let mut keys = slice::from_fn(n, |_| rng.gen::<uint>() % n);
9494

9595
for k in keys.iter() {

branches/try2/src/libgreen/sched.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,12 @@ impl ClosureConverter for UnsafeTaskReceiver {
967967
// worry there.
968968
#[cfg(windows)]
969969
fn new_sched_rng() -> XorShiftRng {
970-
XorShiftRng::new()
970+
match XorShiftRng::new() {
971+
Ok(r) => r,
972+
Err(e) => {
973+
rtabort!("sched: failed to create seeded RNG: {}", e)
974+
}
975+
}
971976
}
972977
#[cfg(unix)]
973978
fn new_sched_rng() -> XorShiftRng {

branches/try2/src/libnative/io/addrinfo.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,8 @@ extern "system" {
9696

9797
#[cfg(windows)]
9898
fn get_error(_: c_int) -> IoError {
99-
use super::translate_error;
100-
10199
unsafe {
102-
translate_error(WSAGetLastError() as i32, true)
100+
IoError::from_errno(WSAGetLastError() as uint, true)
103101
}
104102
}
105103

branches/try2/src/libnative/io/mod.rs

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -86,73 +86,10 @@ fn unimpl() -> IoError {
8686
}
8787
}
8888

89-
fn translate_error(errno: i32, detail: bool) -> IoError {
90-
#[cfg(windows)]
91-
fn get_err(errno: i32) -> (io::IoErrorKind, &'static str) {
92-
match errno {
93-
libc::EOF => (io::EndOfFile, "end of file"),
94-
libc::ERROR_NO_DATA => (io::BrokenPipe, "the pipe is being closed"),
95-
libc::ERROR_FILE_NOT_FOUND => (io::FileNotFound, "file not found"),
96-
libc::ERROR_INVALID_NAME => (io::InvalidInput, "invalid file name"),
97-
libc::WSAECONNREFUSED => (io::ConnectionRefused, "connection refused"),
98-
libc::WSAECONNRESET => (io::ConnectionReset, "connection reset"),
99-
libc::WSAEACCES => (io::PermissionDenied, "permission denied"),
100-
libc::WSAEWOULDBLOCK => {
101-
(io::ResourceUnavailable, "resource temporarily unavailable")
102-
}
103-
libc::WSAENOTCONN => (io::NotConnected, "not connected"),
104-
libc::WSAECONNABORTED => (io::ConnectionAborted, "connection aborted"),
105-
libc::WSAEADDRNOTAVAIL => (io::ConnectionRefused, "address not available"),
106-
libc::WSAEADDRINUSE => (io::ConnectionRefused, "address in use"),
107-
libc::ERROR_BROKEN_PIPE => (io::EndOfFile, "the pipe has ended"),
108-
109-
// libuv maps this error code to EISDIR. we do too. if it is found
110-
// to be incorrect, we can add in some more machinery to only
111-
// return this message when ERROR_INVALID_FUNCTION after certain
112-
// win32 calls.
113-
libc::ERROR_INVALID_FUNCTION => (io::InvalidInput,
114-
"illegal operation on a directory"),
115-
116-
_ => (io::OtherIoError, "unknown error")
117-
}
118-
}
119-
120-
#[cfg(not(windows))]
121-
fn get_err(errno: i32) -> (io::IoErrorKind, &'static str) {
122-
// FIXME: this should probably be a bit more descriptive...
123-
match errno {
124-
libc::EOF => (io::EndOfFile, "end of file"),
125-
libc::ECONNREFUSED => (io::ConnectionRefused, "connection refused"),
126-
libc::ECONNRESET => (io::ConnectionReset, "connection reset"),
127-
libc::EPERM | libc::EACCES =>
128-
(io::PermissionDenied, "permission denied"),
129-
libc::EPIPE => (io::BrokenPipe, "broken pipe"),
130-
libc::ENOTCONN => (io::NotConnected, "not connected"),
131-
libc::ECONNABORTED => (io::ConnectionAborted, "connection aborted"),
132-
libc::EADDRNOTAVAIL => (io::ConnectionRefused, "address not available"),
133-
libc::EADDRINUSE => (io::ConnectionRefused, "address in use"),
134-
libc::ENOENT => (io::FileNotFound, "no such file or directory"),
135-
libc::EISDIR => (io::InvalidInput, "illegal operation on a directory"),
136-
137-
// These two constants can have the same value on some systems, but
138-
// different values on others, so we can't use a match clause
139-
x if x == libc::EAGAIN || x == libc::EWOULDBLOCK =>
140-
(io::ResourceUnavailable, "resource temporarily unavailable"),
141-
142-
_ => (io::OtherIoError, "unknown error")
143-
}
144-
}
145-
146-
let (kind, desc) = get_err(errno);
147-
IoError {
148-
kind: kind,
149-
desc: desc,
150-
detail: if detail {Some(os::last_os_error())} else {None},
151-
}
89+
fn last_error() -> IoError {
90+
IoError::last_error()
15291
}
15392

154-
fn last_error() -> IoError { translate_error(os::errno() as i32, true) }
155-
15693
// unix has nonzero values as errors
15794
fn mkerr_libc(ret: libc::c_int) -> IoResult<()> {
15895
if ret != 0 {

branches/try2/src/libnative/io/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn last_error() -> io::IoError {
120120
extern "system" {
121121
fn WSAGetLastError() -> libc::c_int;
122122
}
123-
super::translate_error(unsafe { WSAGetLastError() }, true)
123+
io::IoError::from_errno(unsafe { WSAGetLastError() } as uint, true)
124124
}
125125

126126
#[cfg(not(windows))]

branches/try2/src/libnative/io/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ fn spawn_process_os(config: p::ProcessConfig,
481481
(bytes[1] << 16) as i32 |
482482
(bytes[2] << 8) as i32 |
483483
(bytes[3] << 0) as i32;
484-
Err(super::translate_error(errno, false))
484+
Err(io::IoError::from_errno(errno as uint, false))
485485
}
486486
Err(e) => {
487487
assert!(e.kind == io::BrokenPipe ||

branches/try2/src/librand/distributions/exponential.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ mod bench {
126126

127127
#[bench]
128128
fn rand_exp(bh: &mut BenchHarness) {
129-
let mut rng = XorShiftRng::new();
129+
let mut rng = XorShiftRng::new().unwrap();
130130
let mut exp = Exp::new(2.71828 * 3.14159);
131131

132132
bh.iter(|| {

branches/try2/src/librand/distributions/gamma.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! The Gamma and derived distributions.
1212
1313
use std::num::Float;
14-
use std::num;
1514
use {Rng, Open01};
1615
use super::normal::StandardNormal;
1716
use super::{IndependentSample, Sample, Exp};
@@ -114,7 +113,7 @@ impl GammaLargeShape {
114113
GammaLargeShape {
115114
shape: shape,
116115
scale: scale,
117-
c: 1. / num::sqrt(9. * d),
116+
c: 1. / (9. * d).sqrt(),
118117
d: d
119118
}
120119
}
@@ -143,7 +142,7 @@ impl IndependentSample<f64> for GammaSmallShape {
143142
fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
144143
let Open01(u) = rng.gen::<Open01<f64>>();
145144

146-
self.large_shape.ind_sample(rng) * num::powf(u, self.inv_shape)
145+
self.large_shape.ind_sample(rng) * u.powf(&self.inv_shape)
147146
}
148147
}
149148
impl IndependentSample<f64> for GammaLargeShape {
@@ -160,7 +159,7 @@ impl IndependentSample<f64> for GammaLargeShape {
160159

161160
let x_sqr = x * x;
162161
if u < 1.0 - 0.0331 * x_sqr * x_sqr ||
163-
num::ln(u) < 0.5 * x_sqr + self.d * (1.0 - v + num::ln(v)) {
162+
u.ln() < 0.5 * x_sqr + self.d * (1.0 - v + v.ln()) {
164163
return self.d * v * self.scale
165164
}
166165
}
@@ -370,14 +369,14 @@ mod bench {
370369
use self::test::BenchHarness;
371370
use std::mem::size_of;
372371
use distributions::IndependentSample;
373-
use {StdRng, RAND_BENCH_N};
372+
use {XorShiftRng, RAND_BENCH_N};
374373
use super::Gamma;
375374

376375

377376
#[bench]
378377
fn bench_gamma_large_shape(bh: &mut BenchHarness) {
379378
let gamma = Gamma::new(10., 1.0);
380-
let mut rng = StdRng::new();
379+
let mut rng = XorShiftRng::new().unwrap();
381380

382381
bh.iter(|| {
383382
for _ in range(0, RAND_BENCH_N) {
@@ -390,7 +389,7 @@ mod bench {
390389
#[bench]
391390
fn bench_gamma_small_shape(bh: &mut BenchHarness) {
392391
let gamma = Gamma::new(0.1, 1.0);
393-
let mut rng = StdRng::new();
392+
let mut rng = XorShiftRng::new().unwrap();
394393

395394
bh.iter(|| {
396395
for _ in range(0, RAND_BENCH_N) {

branches/try2/src/librand/distributions/normal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ mod bench {
193193

194194
#[bench]
195195
fn rand_normal(bh: &mut BenchHarness) {
196-
let mut rng = XorShiftRng::new();
196+
let mut rng = XorShiftRng::new().unwrap();
197197
let mut normal = Normal::new(-2.71828, 3.14159);
198198

199199
bh.iter(|| {

0 commit comments

Comments
 (0)