Skip to content

Commit 90f7683

Browse files
committed
---
yaml --- r: 96178 b: refs/heads/dist-snap c: eef913b h: refs/heads/master v: v3
1 parent 8690490 commit 90f7683

File tree

87 files changed

+344
-307
lines changed

Some content is hidden

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

87 files changed

+344
-307
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 68d5510292ed2f9714568285759ca9ef54d9b48c
9+
refs/heads/dist-snap: eef913b290f668b4f131ead5be65a1615616426b
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/doc/po/ja/tutorial-tasks.md.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ msgstr ""
213213
#. type: Plain text
214214
#: doc/tutorial-tasks.md:102
215215
msgid ""
216-
"The `spawn` function has a very simple type signature: `fn spawn(f: ~fn())`. "
216+
"The `spawn` function has a very simple type signature: `fn spawn(f: proc())`. "
217217
"Because it accepts only owned closures, and owned closures contain only "
218218
"owned data, `spawn` can safely move the entire closure and all its "
219219
"associated state into an entirely different task for execution. Like any "

branches/dist-snap/doc/po/ja/tutorial.md.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,13 +3509,13 @@ msgstr "## 所有クロージャ"
35093509
#. type: Plain text
35103510
#: doc/tutorial.md:1510
35113511
msgid ""
3512-
"Owned closures, written `~fn` in analogy to the `~` pointer type, hold on to "
3512+
"Owned closures, written `proc`, hold on to "
35133513
"things that can safely be sent between processes. They copy the values they "
35143514
"close over, much like managed closures, but they also own them: that is, no "
35153515
"other code can access them. Owned closures are used in concurrent code, "
35163516
"particularly for spawning [tasks][tasks]."
35173517
msgstr ""
3518-
"`~` ポインタ型と同様に `~fn` 型 で書き表される所有クロージャは安全にプロセス"
3518+
"`~` `proc` で書き表される所有クロージャは安全にプロセス"
35193519
"間で送信することができます。所有クローじゃはマネージドクロージャと全く同じよ"
35203520
"うに閉じ込める値をコピーしますが、値を所有します。つまり、他のコードは閉じ込"
35213521
"められた値にアクセスできなくなります。所有クロージャは並列プログラム、特に "
@@ -3666,11 +3666,11 @@ msgstr ""
36663666
#: doc/tutorial.md:1582
36673667
msgid ""
36683668
"`do` is a convenient way to create tasks with the `task::spawn` function. "
3669-
"`spawn` has the signature `spawn(fn: ~fn())`. In other words, it is a "
3669+
"`spawn` has the signature `spawn(fn: proc())`. In other words, it is a "
36703670
"function that takes an owned closure that takes no arguments."
36713671
msgstr ""
36723672
"`task::spawn` 関数を用いてタスクを生成する場合、 `do` を用いると便利です。"
3673-
"`spawn` は、 `spawn(fn: ~fn())` という方を持っています。言い換えると、"
3673+
"`spawn` は、 `spawn(fn: proc())` という方を持っています。言い換えると、"
36743674
"`spawn` は「引数をとらない所有クロージャ」を引数としてとる関数ということで"
36753675
"す。"
36763676

branches/dist-snap/doc/po/tutorial-tasks.md.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ msgstr ""
213213
#. type: Plain text
214214
#: doc/tutorial-tasks.md:102
215215
msgid ""
216-
"The `spawn` function has a very simple type signature: `fn spawn(f: ~fn())`. "
216+
"The `spawn` function has a very simple type signature: `fn spawn(f: proc())`. "
217217
"Because it accepts only owned closures, and owned closures contain only "
218218
"owned data, `spawn` can safely move the entire closure and all its "
219219
"associated state into an entirely different task for execution. Like any "

branches/dist-snap/doc/po/tutorial.md.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,7 @@ msgstr ""
26832683
#. type: Plain text
26842684
#: doc/tutorial.md:1510
26852685
msgid ""
2686-
"Owned closures, written `~fn` in analogy to the `~` pointer type, hold on to "
2686+
"Owned closures, written `proc`, hold on to "
26872687
"things that can safely be sent between processes. They copy the values they "
26882688
"close over, much like managed closures, but they also own them: that is, no "
26892689
"other code can access them. Owned closures are used in concurrent code, "
@@ -2808,7 +2808,7 @@ msgstr ""
28082808
#: doc/tutorial.md:1582
28092809
msgid ""
28102810
"`do` is a convenient way to create tasks with the `task::spawn` function. "
2811-
"`spawn` has the signature `spawn(fn: ~fn())`. In other words, it is a "
2811+
"`spawn` has the signature `spawn(fn: proc())`. In other words, it is a "
28122812
"function that takes an owned closure that takes no arguments."
28132813
msgstr ""
28142814

branches/dist-snap/doc/tutorial-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ _owned types_. The language leaves the implementation details to the standard
9191
library.
9292

9393
The `spawn` function has a very simple type signature: `fn spawn(f:
94-
~fn())`. Because it accepts only owned closures, and owned closures
94+
proc())`. Because it accepts only owned closures, and owned closures
9595
contain only owned data, `spawn` can safely move the entire closure
9696
and all its associated state into an entirely different task for
9797
execution. Like any closure, the function passed to `spawn` may capture

branches/dist-snap/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ pervasively in Rust code.
14091409
14101410
## Owned closures
14111411
1412-
Owned closures, written `~fn` in analogy to the `~` pointer type,
1412+
Owned closures, written `proc`,
14131413
hold on to things that can safely be sent between
14141414
processes. They copy the values they close over, much like managed
14151415
closures, but they also own them: that is, no other code can access
@@ -1484,7 +1484,7 @@ parentheses, where it looks more like a typical block of
14841484
code.
14851485
14861486
`do` is a convenient way to create tasks with the `task::spawn`
1487-
function. `spawn` has the signature `spawn(fn: ~fn())`. In other
1487+
function. `spawn` has the signature `spawn(fn: proc())`. In other
14881488
words, it is a function that takes an owned closure that takes no
14891489
arguments.
14901490

branches/dist-snap/src/libextra/future.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Future<A> {
3636
}
3737

3838
enum FutureState<A> {
39-
Pending(~fn() -> A),
39+
Pending(proc() -> A),
4040
Evaluating,
4141
Forced(A)
4242
}
@@ -92,7 +92,7 @@ impl<A> Future<A> {
9292
Future {state: Forced(val)}
9393
}
9494

95-
pub fn from_fn(f: ~fn() -> A) -> Future<A> {
95+
pub fn from_fn(f: proc() -> A) -> Future<A> {
9696
/*!
9797
* Create a future from a function.
9898
*
@@ -120,7 +120,7 @@ impl<A:Send> Future<A> {
120120
}
121121
}
122122

123-
pub fn spawn(blk: ~fn() -> A) -> Future<A> {
123+
pub fn spawn(blk: proc() -> A) -> Future<A> {
124124
/*!
125125
* Create a future from a unique closure.
126126
*
@@ -137,7 +137,7 @@ impl<A:Send> Future<A> {
137137
Future::from_port(port)
138138
}
139139

140-
pub fn spawn_with<B: Send>(v: B, blk: ~fn(B) -> A) -> Future<A> {
140+
pub fn spawn_with<B: Send>(v: B, blk: proc(B) -> A) -> Future<A> {
141141
/*!
142142
* Create a future from a unique closure taking one argument.
143143
*

branches/dist-snap/src/libextra/task_pool.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::vec;
2323
#[cfg(test)] use std::task::SingleThreaded;
2424

2525
enum Msg<T> {
26-
Execute(~fn(&T)),
26+
Execute(proc(&T)),
2727
Quit
2828
}
2929

@@ -49,15 +49,15 @@ impl<T> TaskPool<T> {
4949
/// local data to be kept around in that task.
5050
pub fn new(n_tasks: uint,
5151
opt_sched_mode: Option<SchedMode>,
52-
init_fn_factory: ~fn() -> ~fn(uint) -> T)
52+
init_fn_factory: &fn() -> proc(uint) -> T)
5353
-> TaskPool<T> {
5454
assert!(n_tasks >= 1);
5555

5656
let channels = do vec::from_fn(n_tasks) |i| {
5757
let (port, chan) = comm::stream::<Msg<T>>();
5858
let init_fn = init_fn_factory();
5959

60-
let task_body: ~fn() = || {
60+
let task_body: proc() = || {
6161
let local_data = init_fn(i);
6262
loop {
6363
match port.recv() {
@@ -88,7 +88,7 @@ impl<T> TaskPool<T> {
8888

8989
/// Executes the function `f` on a task in the pool. The function
9090
/// receives a reference to the local data returned by the `init_fn`.
91-
pub fn execute(&mut self, f: ~fn(&T)) {
91+
pub fn execute(&mut self, f: proc(&T)) {
9292
self.channels[self.next_index].send(Execute(f));
9393
self.next_index += 1;
9494
if self.next_index == self.channels.len() { self.next_index = 0; }
@@ -97,8 +97,8 @@ impl<T> TaskPool<T> {
9797

9898
#[test]
9999
fn test_task_pool() {
100-
let f: ~fn() -> ~fn(uint) -> uint = || {
101-
let g: ~fn(uint) -> uint = |i| i;
100+
let f: &fn() -> proc(uint) -> uint = || {
101+
let g: proc(uint) -> uint = |i| i;
102102
g
103103
};
104104
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);

branches/dist-snap/src/libextra/test.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,22 @@ impl TestDesc {
7474
}
7575
}
7676

77+
/// Represents a benchmark function.
78+
pub trait TDynBenchFn {
79+
fn run(&self, harness: &mut BenchHarness);
80+
}
81+
7782
// A function that runs a test. If the function returns successfully,
7883
// the test succeeds; if the function fails then the test fails. We
7984
// may need to come up with a more clever definition of test in order
8085
// to support isolation of tests into tasks.
8186
pub enum TestFn {
8287
StaticTestFn(extern fn()),
8388
StaticBenchFn(extern fn(&mut BenchHarness)),
84-
StaticMetricFn(~fn(&mut MetricMap)),
85-
DynTestFn(~fn()),
86-
DynMetricFn(~fn(&mut MetricMap)),
87-
DynBenchFn(~fn(&mut BenchHarness))
89+
StaticMetricFn(proc(&mut MetricMap)),
90+
DynTestFn(proc()),
91+
DynMetricFn(proc(&mut MetricMap)),
92+
DynBenchFn(~TDynBenchFn)
8893
}
8994

9095
impl TestFn {
@@ -859,7 +864,7 @@ pub fn run_test(force_ignore: bool,
859864

860865
fn run_test_inner(desc: TestDesc,
861866
monitor_ch: SharedChan<MonitorMsg>,
862-
testfn: ~fn()) {
867+
testfn: proc()) {
863868
let testfn_cell = ::std::cell::Cell::new(testfn);
864869
do task::spawn {
865870
let mut task = task::task();
@@ -878,8 +883,8 @@ pub fn run_test(force_ignore: bool,
878883
}
879884

880885
match testfn {
881-
DynBenchFn(benchfn) => {
882-
let bs = ::test::bench::benchmark(benchfn);
886+
DynBenchFn(bencher) => {
887+
let bs = ::test::bench::benchmark(|harness| bencher.run(harness));
883888
monitor_ch.send((desc, TrBench(bs)));
884889
return;
885890
}

branches/dist-snap/src/libextra/workcache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,14 @@ impl<'self> Prep<'self> {
394394
pub fn exec<T:Send +
395395
Encodable<json::Encoder> +
396396
Decodable<json::Decoder>>(
397-
&'self self, blk: ~fn(&mut Exec) -> T) -> T {
397+
&'self self, blk: proc(&mut Exec) -> T) -> T {
398398
self.exec_work(blk).unwrap()
399399
}
400400

401401
fn exec_work<T:Send +
402402
Encodable<json::Encoder> +
403403
Decodable<json::Decoder>>( // FIXME(#5121)
404-
&'self self, blk: ~fn(&mut Exec) -> T) -> Work<'self, T> {
404+
&'self self, blk: proc(&mut Exec) -> T) -> Work<'self, T> {
405405
let mut bo = Some(blk);
406406

407407
debug!("exec_work: looking up {} and {:?}", self.fn_name,

branches/dist-snap/src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ diagnostic emitter which records when we hit a fatal error. If the task
322322
fails without recording a fatal error then we've encountered a compiler
323323
bug and need to present an error.
324324
*/
325-
pub fn monitor(f: ~fn(@diagnostic::Emitter)) {
325+
pub fn monitor(f: proc(@diagnostic::Emitter)) {
326326
use std::comm::*;
327327

328328
// XXX: This is a hack for newsched since it doesn't support split stacks.

branches/dist-snap/src/librustuv/net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ mod test {
11011101
let handle2 = Cell::new(sched2.make_handle());
11021102
let tasksFriendHandle = Cell::new(sched2.make_handle());
11031103
1104-
let on_exit: ~fn(UnwindResult) = |exit_status| {
1104+
let on_exit: proc(UnwindResult) = |exit_status| {
11051105
handle1.take().send(Shutdown);
11061106
handle2.take().send(Shutdown);
11071107
assert!(exit_status.is_success());
@@ -1115,7 +1115,7 @@ mod test {
11151115
}
11161116
}
11171117
1118-
let test_function: ~fn() = || {
1118+
let test_function: proc() = || {
11191119
let io = unsafe { local_io() };
11201120
let addr = next_test_ip4();
11211121
let maybe_socket = io.udp_bind(addr);

branches/dist-snap/src/librustuv/tty.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ impl TtyWatcher {
3939
// Related:
4040
// - https://github.com/joyent/libuv/issues/982
4141
// - https://github.com/joyent/libuv/issues/988
42-
if unsafe { uvll::guess_handle(fd) != uvll::UV_TTY as libc::c_int } {
42+
let guess = unsafe { uvll::guess_handle(fd) };
43+
if readable && guess != uvll::UV_TTY as libc::c_int {
4344
return Err(UvError(uvll::EBADF));
4445
}
4546

@@ -100,6 +101,10 @@ impl RtioTTY for TtyWatcher {
100101
n => Err(uv_error_to_io_error(UvError(n)))
101102
}
102103
}
104+
105+
fn isatty(&self) -> bool {
106+
unsafe { uvll::guess_handle(self.fd) == uvll::UV_TTY as libc::c_int }
107+
}
103108
}
104109

105110
impl UvHandle<uvll::uv_tty_t> for TtyWatcher {

branches/dist-snap/src/libstd/io/native/file.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ impl rtio::RtioTTY for FileDesc {
308308
fn get_winsize(&mut self) -> Result<(int, int), IoError> {
309309
Err(super::unimpl())
310310
}
311+
fn isatty(&self) -> bool { false }
311312
}
312313

313314
impl Drop for FileDesc {

branches/dist-snap/src/libstd/io/net/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ mod tests {
157157
use io::*;
158158
use rt::comm::oneshot;
159159

160-
fn smalltest(server: ~fn(UnixStream), client: ~fn(UnixStream)) {
160+
fn smalltest(server: proc(UnixStream), client: proc(UnixStream)) {
161161
let server = Cell::new(server);
162162
let client = Cell::new(client);
163163
do run_in_mt_newsched_task {

branches/dist-snap/src/libstd/rand/distributions/gamma.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! The Gamma distribution.
1212
13-
use rand::Rng;
13+
use rand::{Rng, Open01};
1414
use super::{IndependentSample, Sample, StandardNormal, Exp};
1515
use num;
1616

@@ -142,11 +142,7 @@ impl IndependentSample<f64> for Gamma {
142142
}
143143
impl IndependentSample<f64> for GammaSmallShape {
144144
fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
145-
// Need (0, 1) here.
146-
let mut u = rng.gen::<f64>();
147-
while u == 0. {
148-
u = rng.gen();
149-
}
145+
let u = *rng.gen::<Open01<f64>>();
150146

151147
self.large_shape.ind_sample(rng) * num::pow(u, self.inv_shape)
152148
}
@@ -161,12 +157,7 @@ impl IndependentSample<f64> for GammaLargeShape {
161157
}
162158

163159
let v = v_cbrt * v_cbrt * v_cbrt;
164-
// Need (0, 1) here, not [0, 1). This would be faster if
165-
// we were generating an f64 in (0, 1) directly.
166-
let mut u = rng.gen::<f64>();
167-
while u == 0.0 {
168-
u = rng.gen();
169-
}
160+
let u = *rng.gen::<Open01<f64>>();
170161

171162
let x_sqr = x * x;
172163
if u < 1.0 - 0.0331 * x_sqr * x_sqr ||

branches/dist-snap/src/libstd/rand/distributions/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ that do not need to record state.
2323
use iter::range;
2424
use option::{Some, None};
2525
use num;
26-
use rand::{Rng,Rand};
26+
use rand::{Rng, Rand, Open01};
2727
use clone::Clone;
2828

2929
pub use self::range::Range;
@@ -276,10 +276,12 @@ impl Rand for StandardNormal {
276276
let mut x = 1.0f64;
277277
let mut y = 0.0f64;
278278

279-
// FIXME #7755: infinities?
280279
while -2.0 * y < x * x {
281-
x = rng.gen::<f64>().ln() / ziggurat_tables::ZIG_NORM_R;
282-
y = rng.gen::<f64>().ln();
280+
let x_ = *rng.gen::<Open01<f64>>();
281+
let y_ = *rng.gen::<Open01<f64>>();
282+
283+
x = x_.ln() / ziggurat_tables::ZIG_NORM_R;
284+
y = y_.ln();
283285
}
284286

285287
if u < 0.0 { x - ziggurat_tables::ZIG_NORM_R } else { ziggurat_tables::ZIG_NORM_R - x }

0 commit comments

Comments
 (0)