Skip to content

Commit d70ca1f

Browse files
committed
---
yaml --- r: 145055 b: refs/heads/try2 c: f853f0b h: refs/heads/master i: 145053: c83c14d 145051: dc868cd 145047: c85e1c8 145039: cc8052b 145023: 436b841 v: v3
1 parent 20f3e22 commit d70ca1f

File tree

256 files changed

+6918
-3660
lines changed

Some content is hidden

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

256 files changed

+6918
-3660
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: d0462f070cf2a94a8720e6d5b939f32ba330c4eb
8+
refs/heads/try2: f853f0b2d65aef97fb88d569d5636eaeae6bb369
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,8 @@ Supported traits for `deriving` are:
17171717
* `Clone` and `DeepClone`, to perform (deep) copies.
17181718
* `IterBytes`, to iterate over the bytes in a data type.
17191719
* `Rand`, to create a random instance of a data type.
1720-
* `Zero`, to create an zero (or empty) instance of a data type.
1720+
* `Default`, to create an empty instance of a data type.
1721+
* `Zero`, to create an zero instance of a numeric data type.
17211722
* `ToStr`, to convert to a string. For a type with this instance,
17221723
`obj.to_str()` has similar output as `fmt!("%?", obj)`, but it differs in that
17231724
each constituent field of the type must also implement `ToStr` and will have
@@ -2459,25 +2460,12 @@ do k(3) |j| {
24592460
### For expressions
24602461

24612462
~~~~~~~~{.ebnf .gram}
2462-
for_expr : "for" expr [ '|' ident_list '|' ] ? '{' block '}' ;
2463+
for_expr : "for" pat "in" expr '{' block '}' ;
24632464
~~~~~~~~
24642465

2465-
A _for expression_ is similar to a [`do` expression](#do-expressions),
2466-
in that it provides a special block-form of lambda expression,
2467-
suited to passing the `block` function to a higher-order function implementing a loop.
2468-
2469-
In contrast to a `do` expression, a `for` expression is designed to work
2470-
with methods such as `each` and `times`, that require the body block to
2471-
return a boolean. The `for` expression accommodates this by implicitly
2472-
returning `true` at the end of each block, unless a `break` expression
2473-
is evaluated.
2474-
2475-
In addition, [`break`](#break-expressions) and [`loop`](#loop-expressions) expressions
2476-
are rewritten inside `for` expressions in the same way that `return` expressions are,
2477-
with a combination of local flag variables,
2478-
and early boolean-valued returns from the `block` function,
2479-
such that the meaning of `break` and `loop` is preserved in a primitive loop
2480-
when rewritten as a `for` loop controlled by a higher order function.
2466+
A `for` expression is a syntactic construct for looping
2467+
over elements provided by an implementation of
2468+
`std::iterator::Iterator`.
24812469

24822470
An example of a for loop over the contents of a vector:
24832471

branches/try2/doc/rustpkg.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ A valid workspace must contain each of the following subdirectories:
5252
rustpkg will install libraries for bar to `foo/lib/x86_64-apple-darwin/`.
5353
The libraries will have names of the form `foo/lib/x86_64-apple-darwin/libbar-[hash].dylib`,
5454
where [hash] is a hash of the package ID.
55-
* 'bin/': `rustpkg install` installs executable binaries into a target-specific subdirectory of this directory.
55+
* 'bin/': `rustpkg install` installs executable binaries into this directory.
5656

57-
For example, on a 64-bit machine running Mac OS X,
58-
if `foo` is a workspace, containing the package `bar`,
59-
rustpkg will install executables for `bar` to
60-
`foo/bin/x86_64-apple-darwin/`.
61-
The executables will have names of the form `foo/bin/x86_64-apple-darwin/bar`.
57+
For example, rustpkg will install executables for `bar` to
58+
`foo/bin`.
59+
The executables will have names of the form `foo/bin/bar`.
6260
* 'build/': `rustpkg build` stores temporary build artifacts in a target-specific subdirectory of this directory.
6361

6462
For example, on a 64-bit machine running Mac OS X,
@@ -85,6 +83,12 @@ rustpkg also interprets any dependencies on such a package ID literally
8583
Thus, `github.com/mozilla/rust#5c4cd30f80` is also a valid package ID,
8684
since git can deduce that 5c4cd30f80 refers to a revision of the desired repository.
8785

86+
A package identifier can name a subdirectory of another package.
87+
For example, if `foo` is a workspace, and `foo/src/bar/lib.rs` exists,
88+
as well as `foo/src/bar/extras/baz/lib.rs`,
89+
then both `bar` and `bar/extras/baz` are valid package identifiers
90+
in the workspace `foo`.
91+
8892
## Source files
8993

9094
rustpkg searches for four different fixed filenames in order to determine the crates to build:
@@ -140,9 +144,11 @@ but not in their `lib` or `bin` directories.
140144

141145
## install
142146

143-
`rustpkg install foo` builds the libraries and/or executables that are targets for `foo`,
144-
and then installs them either into `foo`'s `lib` and `bin` directories,
145-
or into the `lib` and `bin` subdirectories of the first entry in `RUST_PATH`.
147+
`rustpkg install foo` builds the libraries and/or executables that are targets for `foo`.
148+
If `RUST_PATH` is declared as an environment variable, then rustpkg installs the
149+
libraries and executables into the `lib` and `bin` subdirectories
150+
of the first entry in `RUST_PATH`.
151+
Otherwise, it installs them into `foo`'s `lib` and `bin` directories.
146152

147153
## test
148154

branches/try2/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,7 @@ enum ABC { A, B, C }
22492249

22502250
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
22512251
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `DeepClone`,
2252-
`IterBytes`, `Rand`, `Zero`, and `ToStr`.
2252+
`IterBytes`, `Rand`, `Default`, `Zero`, and `ToStr`.
22532253

22542254
# Crates and the module system
22552255

branches/try2/mk/rt.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
7575
rt/rust_rng.cpp \
7676
rt/rust_upcall.cpp \
7777
rt/rust_uv.cpp \
78-
rt/rust_crate_map.cpp \
7978
rt/isaac/randport.cpp \
8079
rt/miniz.cpp \
8180
rt/memory_region.cpp \

branches/try2/src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
309309
let filename = path.filename();
310310
let p = path.pop();
311311
let dir = p.filename();
312-
fmt!("%s/%s", dir.unwrap_or_default(""), filename.unwrap_or_default(""))
312+
fmt!("%s/%s", dir.unwrap_or(""), filename.unwrap_or(""))
313313
}
314314

315315
test::DynTestName(fmt!("[%s] %s",

branches/try2/src/libextra/base64.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,8 @@ mod test {
315315
use std::vec;
316316
317317
do 1000.times {
318-
let v: ~[u8] = do vec::build |push| {
319-
do task_rng().gen_uint_range(1, 100).times {
320-
push(random());
321-
}
322-
};
318+
let times = task_rng().gen_uint_range(1, 100);
319+
let v = vec::from_fn(times, |_| random::<u8>());
323320
assert_eq!(v.to_base64(STANDARD).from_base64().unwrap(), v);
324321
}
325322
}

branches/try2/src/libextra/comm.rs

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -90,9 +90,55 @@ pub fn DuplexStream<T:Send,U:Send>()
9090
})
9191
}
9292

93+
/// An extension of `pipes::stream` that provides synchronous message sending.
94+
pub struct SyncChan<T> { priv duplex_stream: DuplexStream<T, ()> }
95+
/// An extension of `pipes::stream` that acknowledges each message received.
96+
pub struct SyncPort<T> { priv duplex_stream: DuplexStream<(), T> }
97+
98+
impl<T: Send> GenericChan<T> for SyncChan<T> {
99+
fn send(&self, val: T) {
100+
assert!(self.try_send(val), "SyncChan.send: receiving port closed");
101+
}
102+
}
103+
104+
impl<T: Send> GenericSmartChan<T> for SyncChan<T> {
105+
/// Sends a message, or report if the receiver has closed the connection before receiving.
106+
fn try_send(&self, val: T) -> bool {
107+
self.duplex_stream.try_send(val) && self.duplex_stream.try_recv().is_some()
108+
}
109+
}
110+
111+
impl<T: Send> GenericPort<T> for SyncPort<T> {
112+
fn recv(&self) -> T {
113+
self.try_recv().expect("SyncPort.recv: sending channel closed")
114+
}
115+
116+
fn try_recv(&self) -> Option<T> {
117+
do self.duplex_stream.try_recv().map_move |val| {
118+
self.duplex_stream.try_send(());
119+
val
120+
}
121+
}
122+
}
123+
124+
impl<T: Send> Peekable<T> for SyncPort<T> {
125+
fn peek(&self) -> bool {
126+
self.duplex_stream.peek()
127+
}
128+
}
129+
130+
/// Creates a stream whose channel, upon sending a message, blocks until the message is received.
131+
pub fn rendezvous<T: Send>() -> (SyncPort<T>, SyncChan<T>) {
132+
let (chan_stream, port_stream) = DuplexStream();
133+
(SyncPort { duplex_stream: port_stream }, SyncChan { duplex_stream: chan_stream })
134+
}
135+
93136
#[cfg(test)]
94137
mod test {
95-
use comm::DuplexStream;
138+
use comm::{DuplexStream, rendezvous};
139+
use std::rt::test::run_in_newsched_task;
140+
use std::task::spawn_unlinked;
141+
96142

97143
#[test]
98144
pub fn DuplexStream1() {
@@ -104,4 +150,58 @@ mod test {
104150
assert!(left.recv() == 123);
105151
assert!(right.recv() == ~"abc");
106152
}
153+
154+
#[test]
155+
pub fn basic_rendezvous_test() {
156+
let (port, chan) = rendezvous();
157+
158+
do spawn {
159+
chan.send("abc");
160+
}
161+
162+
assert!(port.recv() == "abc");
163+
}
164+
165+
#[test]
166+
fn recv_a_lot() {
167+
// Rendezvous streams should be able to handle any number of messages being sent
168+
do run_in_newsched_task {
169+
let (port, chan) = rendezvous();
170+
do spawn {
171+
do 1000000.times { chan.send(()) }
172+
}
173+
do 1000000.times { port.recv() }
174+
}
175+
}
176+
177+
#[test]
178+
fn send_and_fail_and_try_recv() {
179+
let (port, chan) = rendezvous();
180+
do spawn_unlinked {
181+
chan.duplex_stream.send(()); // Can't access this field outside this module
182+
fail!()
183+
}
184+
port.recv()
185+
}
186+
187+
#[test]
188+
fn try_send_and_recv_then_fail_before_ack() {
189+
let (port, chan) = rendezvous();
190+
do spawn_unlinked {
191+
port.duplex_stream.recv();
192+
fail!()
193+
}
194+
chan.try_send(());
195+
}
196+
197+
#[test]
198+
#[should_fail]
199+
fn send_and_recv_then_fail_before_ack() {
200+
let (port, chan) = rendezvous();
201+
do spawn_unlinked {
202+
port.duplex_stream.recv();
203+
fail!()
204+
}
205+
chan.send(());
206+
}
107207
}

branches/try2/src/libextra/fileinput.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -417,20 +417,23 @@ mod test {
417417

418418
use super::{FileInput, make_path_option_vec, input_vec, input_vec_state};
419419

420-
use std::io;
420+
use std::rt::io;
421+
use std::rt::io::Writer;
422+
use std::rt::io::file;
421423
use std::uint;
422424
use std::vec;
423425

424426
fn make_file(path : &Path, contents: &[~str]) {
425-
let file = io::file_writer(path, [io::Create, io::Truncate]).unwrap();
427+
let mut file = file::open(path, io::CreateOrTruncate, io::Write).unwrap();
426428

427429
for str in contents.iter() {
428-
file.write_str(*str);
429-
file.write_char('\n');
430+
file.write(str.as_bytes());
431+
file.write(['\n' as u8]);
430432
}
431433
}
432434

433435
#[test]
436+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
434437
fn test_make_path_option_vec() {
435438
let strs = [~"some/path",
436439
~"some/other/path"];
@@ -445,6 +448,7 @@ mod test {
445448
}
446449
447450
#[test]
451+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
448452
fn test_fileinput_read_byte() {
449453
let filenames = make_path_option_vec(vec::from_fn(
450454
3,
@@ -475,6 +479,7 @@ mod test {
475479
}
476480
477481
#[test]
482+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
478483
fn test_fileinput_read() {
479484
let filenames = make_path_option_vec(vec::from_fn(
480485
3,
@@ -495,6 +500,7 @@ mod test {
495500
}
496501

497502
#[test]
503+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
498504
fn test_input_vec() {
499505
let mut all_lines = ~[];
500506
let filenames = make_path_option_vec(vec::from_fn(
@@ -518,6 +524,7 @@ mod test {
518524
}
519525

520526
#[test]
527+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
521528
fn test_input_vec_state() {
522529
let filenames = make_path_option_vec(vec::from_fn(
523530
3,
@@ -540,6 +547,7 @@ mod test {
540547
}
541548

542549
#[test]
550+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
543551
fn test_empty_files() {
544552
let filenames = make_path_option_vec(vec::from_fn(
545553
3,
@@ -564,18 +572,21 @@ mod test {
564572
}
565573
566574
#[test]
575+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
567576
fn test_no_trailing_newline() {
568577
let f1 =
569578
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
570579
let f2 =
571580
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-2.tmp"));
572581
573-
let wr = io::file_writer(f1.get_ref(),
574-
[io::Create, io::Truncate]).unwrap();
575-
wr.write_str("1\n2");
576-
let wr = io::file_writer(f2.get_ref(),
577-
[io::Create, io::Truncate]).unwrap();
578-
wr.write_str("3\n4");
582+
{
583+
let mut wr = file::open(f1.get_ref(), io::CreateOrTruncate,
584+
io::Write).unwrap();
585+
wr.write("1\n2".as_bytes());
586+
let mut wr = file::open(f2.get_ref(), io::CreateOrTruncate,
587+
io::Write).unwrap();
588+
wr.write("3\n4".as_bytes());
589+
}
579590
580591
let mut lines = ~[];
581592
do input_vec(~[f1, f2]) |line| {
@@ -587,6 +598,7 @@ mod test {
587598
588599
589600
#[test]
601+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
590602
fn test_next_file() {
591603
let filenames = make_path_option_vec(vec::from_fn(
592604
3,
@@ -618,6 +630,7 @@ mod test {
618630
619631
#[test]
620632
#[should_fail]
633+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
621634
fn test_input_vec_missing_file() {
622635
do input_vec(make_path_option_vec([~"this/file/doesnt/exist"], true)) |line| {
623636
println(line);

0 commit comments

Comments
 (0)