Skip to content

Commit 897d38f

Browse files
committed
---
yaml --- r: 128221 b: refs/heads/try c: aa98b25 h: refs/heads/master i: 128219: 4321201 v: v3
1 parent 5d6b944 commit 897d38f

25 files changed

+879
-85
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: cb9c1e0e702f4a1a5dfc909b15b74e8556013c06
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: aa98b25c4f0c10729dff37c699904ad57b8fbda8
5-
refs/heads/try: 9434920b24405588d22c17436b184736881ed933
5+
refs/heads/try: aa98b25c4f0c10729dff37c699904ad57b8fbda8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/compiletest/runtest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use std::os;
3030
use std::str;
3131
use std::string::String;
3232
use std::task;
33+
use std::time::Duration;
3334
use test::MetricMap;
3435

3536
pub fn run(config: Config, testfile: String) {
@@ -400,7 +401,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
400401
.expect(format!("failed to exec `{}`", config.adb_path).as_slice());
401402
loop {
402403
//waiting 1 second for gdbserver start
403-
timer::sleep(1000);
404+
timer::sleep(Duration::milliseconds(1000));
404405
let result = task::try(proc() {
405406
tcp::TcpStream::connect("127.0.0.1", 5039).unwrap();
406407
});

branches/try/src/doc/guide-runtime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ itself, yet again implying that they are not defined in the standard library.
128128
The full complement of runtime features is defined by the [`Runtime`
129129
trait](std/rt/trait.Runtime.html) and the [`Task`
130130
struct](std/rt/task/struct.Task.html). A `Task` is constant among all runtime
131-
implementations, but each runtime implements has its own implementation of the
131+
implementations, but each runtime has its own implementation of the
132132
`Runtime` trait.
133133

134134
The local `Task` stores the runtime value inside of itself, and then ownership

branches/try/src/doc/guide-testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ per-iteration speed of.
198198

199199
For benchmarks relating to processing/generating data, one can set the
200200
`bytes` field to the number of bytes consumed/produced in each
201-
iteration; this will used to show the throughput of the benchmark.
201+
iteration; this will be used to show the throughput of the benchmark.
202202
This must be the amount used in each iteration, *not* the total
203203
amount.
204204

branches/try/src/doc/guide-unsafe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ explicitly with, respectively, `value as *const T` and `value as *mut T`).
137137

138138
Going the opposite direction, from `*const` to a reference `&`, is not
139139
safe. A `&T` is always valid, and so, at a minimum, the raw pointer
140-
`*const T` has to be a valid to a valid instance of type `T`. Furthermore,
140+
`*const T` has to point to a valid instance of type `T`. Furthermore,
141141
the resulting pointer must satisfy the aliasing and mutability laws of
142142
references. The compiler assumes these properties are true for any
143143
references, no matter how they are created, and so any conversion from

branches/try/src/doc/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ This is not the same as this, which won't compile:
666666
```{ignore}
667667
let x = 5i;
668668
669-
let y: int = if x == 5 { 10i; } else { 15i; };
669+
let y: int = if x == 5i { 10i; } else { 15i; };
670670
```
671671

672672
Note the semicolons after the 10 and 15. Rust will give us the following error:

branches/try/src/doc/rust.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,9 @@ A *static item* is a named _constant value_ stored in the global data section of
13561356
Immutable static items are stored in the read-only data section.
13571357
The constant value bound to a static item is, like all constant values, evaluated at compile time.
13581358
Static items have the `static` lifetime, which outlives all other lifetimes in a Rust program.
1359+
Only values stored in the global data section (such as string constants
1360+
and static items) can have the `static` lifetime;
1361+
dynamically constructed values cannot safely be assigned the `static` lifetime.
13591362
Static items are declared with the `static` keyword.
13601363
A static item must have a _constant expression_ giving its definition.
13611364

@@ -3621,7 +3624,10 @@ There are four varieties of pointer in Rust:
36213624
References arise by (automatic) conversion from owning pointers, managed pointers,
36223625
or by applying the borrowing operator `&` to some other value,
36233626
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3624-
References are written `&content`, or in some cases `&'f content` for some lifetime-variable `f`,
3627+
A borrow expression is written `&content`.
3628+
3629+
A reference type is written `&'f type` for some lifetime-variable `f`,
3630+
or just `&type` when the lifetime can be elided;
36253631
for example `&int` means a reference to an integer.
36263632
Copying a reference is a "shallow" operation:
36273633
it involves only copying the pointer itself.

branches/try/src/libgreen/sched.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ mod test {
10291029
use std::rt::task::TaskOpts;
10301030
use std::rt::task::Task;
10311031
use std::rt::local::Local;
1032+
use std::time::Duration;
10321033

10331034
use {TaskState, PoolConfig, SchedPool};
10341035
use basic;
@@ -1291,7 +1292,7 @@ mod test {
12911292
// doesn't exit before emptying the work queue
12921293
pool.spawn(TaskOpts::new(), proc() {
12931294
spawn(proc() {
1294-
timer::sleep(10);
1295+
timer::sleep(Duration::milliseconds(10));
12951296
});
12961297
});
12971298

branches/try/src/libstd/io/net/tcp.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ use io::net::addrinfo::get_host_addresses;
2727
use io::net::ip::SocketAddr;
2828
use io::{IoError, ConnectionFailed, InvalidInput};
2929
use io::{Reader, Writer, Listener, Acceptor};
30+
use io::{standard_error, TimedOut};
3031
use from_str::FromStr;
3132
use kinds::Send;
3233
use option::{None, Some, Option};
3334
use boxed::Box;
3435
use rt::rtio::{IoFactory, LocalIo, RtioSocket, RtioTcpListener};
3536
use rt::rtio::{RtioTcpAcceptor, RtioTcpStream};
3637
use rt::rtio;
38+
use time::Duration;
3739

3840
/// A structure which represents a TCP stream between a local socket and a
3941
/// remote socket.
@@ -92,21 +94,28 @@ impl TcpStream {
9294
}
9395

9496
/// Creates a TCP connection to a remote socket address, timing out after
95-
/// the specified number of milliseconds.
97+
/// the specified duration.
9698
///
9799
/// This is the same as the `connect` method, except that if the timeout
98100
/// specified (in milliseconds) elapses before a connection is made an error
99101
/// will be returned. The error's kind will be `TimedOut`.
100102
///
101103
/// Note that the `addr` argument may one day be split into a separate host
102104
/// and port, similar to the API seen in `connect`.
105+
///
106+
/// If a `timeout` with zero or negative duration is specified then
107+
/// the function returns `Err`, with the error kind set to `TimedOut`.
103108
#[experimental = "the timeout argument may eventually change types"]
104109
pub fn connect_timeout(addr: SocketAddr,
105-
timeout_ms: u64) -> IoResult<TcpStream> {
110+
timeout: Duration) -> IoResult<TcpStream> {
111+
if timeout <= Duration::milliseconds(0) {
112+
return Err(standard_error(TimedOut));
113+
}
114+
106115
let SocketAddr { ip, port } = addr;
107116
let addr = rtio::SocketAddr { ip: super::to_rtio(ip), port: port };
108117
LocalIo::maybe_raise(|io| {
109-
io.tcp_connect(addr, Some(timeout_ms)).map(TcpStream::new)
118+
io.tcp_connect(addr, Some(timeout.num_milliseconds() as u64)).map(TcpStream::new)
110119
}).map_err(IoError::from_rtio_error)
111120
}
112121

@@ -164,13 +173,14 @@ impl TcpStream {
164173
/// # #![allow(unused_must_use)]
165174
/// use std::io::timer;
166175
/// use std::io::TcpStream;
176+
/// use std::time::Duration;
167177
///
168178
/// let mut stream = TcpStream::connect("127.0.0.1", 34254).unwrap();
169179
/// let stream2 = stream.clone();
170180
///
171181
/// spawn(proc() {
172182
/// // close this stream after one second
173-
/// timer::sleep(1000);
183+
/// timer::sleep(Duration::seconds(1));
174184
/// let mut stream = stream2;
175185
/// stream.close_read();
176186
/// });

branches/try/src/libstd/io/net/unix.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ use prelude::*;
2929
use c_str::ToCStr;
3030
use clone::Clone;
3131
use io::{Listener, Acceptor, Reader, Writer, IoResult, IoError};
32+
use io::{standard_error, TimedOut};
3233
use kinds::Send;
3334
use boxed::Box;
3435
use rt::rtio::{IoFactory, LocalIo, RtioUnixListener};
3536
use rt::rtio::{RtioUnixAcceptor, RtioPipe};
37+
use time::Duration;
3638

3739
/// A stream which communicates over a named pipe.
3840
pub struct UnixStream {
@@ -66,11 +68,18 @@ impl UnixStream {
6668
///
6769
/// This function is similar to `connect`, except that if `timeout_ms`
6870
/// elapses the function will return an error of kind `TimedOut`.
71+
///
72+
/// If a `timeout` with zero or negative duration is specified then
73+
/// the function returns `Err`, with the error kind set to `TimedOut`.
6974
#[experimental = "the timeout argument is likely to change types"]
7075
pub fn connect_timeout<P: ToCStr>(path: &P,
71-
timeout_ms: u64) -> IoResult<UnixStream> {
76+
timeout: Duration) -> IoResult<UnixStream> {
77+
if timeout <= Duration::milliseconds(0) {
78+
return Err(standard_error(TimedOut));
79+
}
80+
7281
LocalIo::maybe_raise(|io| {
73-
let s = io.unix_connect(&path.to_c_str(), Some(timeout_ms));
82+
let s = io.unix_connect(&path.to_c_str(), Some(timeout.num_milliseconds() as u64));
7483
s.map(|p| UnixStream { obj: p })
7584
}).map_err(IoError::from_rtio_error)
7685
}
@@ -499,13 +508,25 @@ mod tests {
499508

500509
iotest!(fn connect_timeout_error() {
501510
let addr = next_test_unix();
502-
assert!(UnixStream::connect_timeout(&addr, 100).is_err());
511+
assert!(UnixStream::connect_timeout(&addr, Duration::milliseconds(100)).is_err());
503512
})
504513

505514
iotest!(fn connect_timeout_success() {
506515
let addr = next_test_unix();
507516
let _a = UnixListener::bind(&addr).unwrap().listen().unwrap();
508-
assert!(UnixStream::connect_timeout(&addr, 100).is_ok());
517+
assert!(UnixStream::connect_timeout(&addr, Duration::milliseconds(100)).is_ok());
518+
})
519+
520+
iotest!(fn connect_timeout_zero() {
521+
let addr = next_test_unix();
522+
let _a = UnixListener::bind(&addr).unwrap().listen().unwrap();
523+
assert!(UnixStream::connect_timeout(&addr, Duration::milliseconds(0)).is_err());
524+
})
525+
526+
iotest!(fn connect_timeout_negative() {
527+
let addr = next_test_unix();
528+
let _a = UnixListener::bind(&addr).unwrap().listen().unwrap();
529+
assert!(UnixStream::connect_timeout(&addr, Duration::milliseconds(-1)).is_err());
509530
})
510531

511532
iotest!(fn close_readwrite_smoke() {

branches/try/src/libstd/io/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ mod tests {
976976
assert!(!p.wait().unwrap().success());
977977
return
978978
}
979-
timer::sleep(100);
979+
timer::sleep(Duration::milliseconds(100));
980980
}
981981
fail!("never saw the child go away");
982982
})

branches/try/src/libstd/io/signal.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ mod test_unix {
167167
use comm::Empty;
168168
use io::timer;
169169
use super::{Listener, Interrupt};
170+
use time::Duration;
170171

171172
fn sigint() {
172173
unsafe {
@@ -179,7 +180,7 @@ mod test_unix {
179180
let mut signal = Listener::new();
180181
signal.register(Interrupt).unwrap();
181182
sigint();
182-
timer::sleep(10);
183+
timer::sleep(Duration::milliseconds(10));
183184
match signal.rx.recv() {
184185
Interrupt => (),
185186
s => fail!("Expected Interrupt, got {:?}", s),
@@ -193,7 +194,7 @@ mod test_unix {
193194
s1.register(Interrupt).unwrap();
194195
s2.register(Interrupt).unwrap();
195196
sigint();
196-
timer::sleep(10);
197+
timer::sleep(Duration::milliseconds(10));
197198
match s1.rx.recv() {
198199
Interrupt => (),
199200
s => fail!("Expected Interrupt, got {:?}", s),
@@ -212,7 +213,7 @@ mod test_unix {
212213
s2.register(Interrupt).unwrap();
213214
s2.unregister(Interrupt);
214215
sigint();
215-
timer::sleep(10);
216+
timer::sleep(Duration::milliseconds(10));
216217
assert_eq!(s2.rx.try_recv(), Err(Empty));
217218
}
218219
}

branches/try/src/libstd/io/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ macro_rules! iotest (
3939
use io::process::*;
4040
use rt::running_on_valgrind;
4141
use str;
42+
use time::Duration;
4243

4344
fn f() $b
4445

0 commit comments

Comments
 (0)