Skip to content

Commit 107d571

Browse files
committed
---
yaml --- r: 65203 b: refs/heads/master c: 41c2168 h: refs/heads/master i: 65201: ff8749f 65199: d9f5bb6 v: v3
1 parent de04a65 commit 107d571

File tree

814 files changed

+11746
-16746
lines changed

Some content is hidden

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

814 files changed

+11746
-16746
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ee1b41981873805c69a122c0e6ed25d39e55b535
2+
refs/heads/master: 41c21685dd149fb95dededfb4edaf87c6603c099
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/doc/rust.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,6 +2250,14 @@ do_expr : "do" expr [ '|' ident_list '|' ] ? '{' block '}' ;
22502250
A _do expression_ provides a more-familiar block-syntax for a [lambda expression](#lambda-expressions),
22512251
including a special translation of [return expressions](#return-expressions) inside the supplied block.
22522252

2253+
Any occurrence of a [return expression](#return-expressions)
2254+
inside this `block` expression is rewritten
2255+
as a reference to an (anonymous) flag set in the caller's environment,
2256+
which is checked on return from the `expr` and, if set,
2257+
causes a corresponding return from the caller.
2258+
In this way, the meaning of `return` statements in language built-in control blocks is preserved,
2259+
if they are rewritten using lambda functions and `do` expressions as abstractions.
2260+
22532261
The optional `ident_list` and `block` provided in a `do` expression are parsed as though they constitute a lambda expression;
22542262
if the `ident_list` is missing, an empty `ident_list` is implied.
22552263

@@ -2296,19 +2304,15 @@ A _for expression_ is similar to a [`do` expression](#do-expressions),
22962304
in that it provides a special block-form of lambda expression,
22972305
suited to passing the `block` function to a higher-order function implementing a loop.
22982306

2299-
Like a `do` expression, a `return` expression inside a `for` expresison is rewritten,
2300-
to access a local flag that causes an early return in the caller.
2301-
2302-
Additionally, any occurrence of a [return expression](#return-expressions)
2303-
inside the `block` of a `for` expression is rewritten
2304-
as a reference to an (anonymous) flag set in the caller's environment,
2305-
which is checked on return from the `expr` and, if set,
2306-
causes a corresponding return from the caller.
2307-
In this way, the meaning of `return` statements in language built-in control blocks is preserved,
2308-
if they are rewritten using lambda functions and `do` expressions as abstractions.
2307+
In contrast to a `do` expression, a `for` expression is designed to work
2308+
with methods such as `each` and `times`, that require the body block to
2309+
return a boolean. The `for` expression accommodates this by implicitly
2310+
returning `true` at the end of each block, unless a `break` expression
2311+
is evaluated.
23092312

2310-
Like `return` expressions, any [`break`](#break-expressions) and [`loop`](#loop-expressions) expressions
2311-
are rewritten inside `for` expressions, with a combination of local flag variables,
2313+
In addition, [`break`](#break-expressions) and [`loop`](#loop-expressions) expressions
2314+
are rewritten inside `for` expressions in the same way that `return` expressions are,
2315+
with a combination of local flag variables,
23122316
and early boolean-valued returns from the `block` function,
23132317
such that the meaning of `break` and `loop` is preserved in a primitive loop
23142318
when rewritten as a `for` loop controlled by a higher order function.

trunk/doc/tutorial-tasks.md

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,24 @@ in the core and standard libraries, which are still under development
4343
and do not always present a consistent or complete interface.
4444

4545
For your reference, these are the standard modules involved in Rust
46-
concurrency at this writing.
46+
concurrency at this writing:
4747

48-
* [`core::task`] - All code relating to tasks and task scheduling
49-
* [`core::comm`] - The message passing interface
50-
* [`core::pipes`] - The underlying messaging infrastructure
51-
* [`std::comm`] - Additional messaging types based on `core::pipes`
52-
* [`std::sync`] - More exotic synchronization tools, including locks
48+
* [`core::task`] - All code relating to tasks and task scheduling,
49+
* [`core::comm`] - The message passing interface,
50+
* [`core::pipes`] - The underlying messaging infrastructure,
51+
* [`std::comm`] - Additional messaging types based on `core::pipes`,
52+
* [`std::sync`] - More exotic synchronization tools, including locks,
5353
* [`std::arc`] - The ARC (atomically reference counted) type,
54-
for safely sharing immutable data
54+
for safely sharing immutable data,
55+
* [`std::future`] - A type representing values that may be computed concurrently and retrieved at a later time.
5556

5657
[`core::task`]: core/task.html
5758
[`core::comm`]: core/comm.html
5859
[`core::pipes`]: core/pipes.html
5960
[`std::comm`]: std/comm.html
6061
[`std::sync`]: std/sync.html
6162
[`std::arc`]: std/arc.html
63+
[`std::future`]: std/future.html
6264

6365
# Basics
6466

@@ -70,7 +72,7 @@ closure in the new task.
7072

7173
~~~~
7274
# use core::io::println;
73-
use core::task::spawn;
75+
# use core::task::spawn;
7476
7577
// Print something profound in a different task using a named function
7678
fn print_message() { println("I am running in a different task!"); }
@@ -145,8 +147,8 @@ endpoint. Consider the following example of calculating two results
145147
concurrently:
146148

147149
~~~~
148-
use core::task::spawn;
149-
use core::comm::{stream, Port, Chan};
150+
# use core::task::spawn;
151+
# use core::comm::{stream, Port, Chan};
150152
151153
let (port, chan): (Port<int>, Chan<int>) = stream();
152154
@@ -233,7 +235,7 @@ Instead we can use a `SharedChan`, a type that allows a single
233235

234236
~~~
235237
# use core::task::spawn;
236-
use core::comm::{stream, SharedChan};
238+
# use core::comm::{stream, SharedChan};
237239
238240
let (port, chan) = stream();
239241
let chan = SharedChan::new(chan);
@@ -282,6 +284,51 @@ let result = ports.foldl(0, |accum, port| *accum + port.recv() );
282284
# fn some_expensive_computation(_i: uint) -> int { 42 }
283285
~~~
284286

287+
## Futures
288+
With `std::future`, rust has a mechanism for requesting a computation and getting the result
289+
later.
290+
291+
The basic example below illustrates this.
292+
~~~
293+
# fn make_a_sandwich() {};
294+
fn fib(n: uint) -> uint {
295+
// lengthy computation returning an uint
296+
12586269025
297+
}
298+
299+
let mut delayed_fib = std::future::spawn (|| fib(50) );
300+
make_a_sandwich();
301+
println(fmt!("fib(50) = %?", delayed_fib.get()))
302+
~~~
303+
304+
The call to `future::spawn` returns immediately a `future` object regardless of how long it
305+
takes to run `fib(50)`. You can then make yourself a sandwich while the computation of `fib` is
306+
running. The result of the execution of the method is obtained by calling `get` on the future.
307+
This call will block until the value is available (*i.e.* the computation is complete). Note that
308+
the future needs to be mutable so that it can save the result for next time `get` is called.
309+
310+
Here is another example showing how futures allow you to background computations. The workload will
311+
be distributed on the available cores.
312+
~~~
313+
fn partial_sum(start: uint) -> f64 {
314+
let mut local_sum = 0f64;
315+
for uint::range(start*100000, (start+1)*100000) |num| {
316+
local_sum += (num as f64 + 1.0).pow(-2.0);
317+
}
318+
local_sum
319+
}
320+
321+
fn main() {
322+
let mut futures = vec::from_fn(1000, |ind| do std::future::spawn { partial_sum(ind) });
323+
324+
let mut final_res = 0f64;
325+
for futures.each_mut |ft| {
326+
final_res += ft.get();
327+
}
328+
println(fmt!("π^2/6 is not far from : %?", final_res));
329+
}
330+
~~~
331+
285332
# Handling task failure
286333

287334
Rust has a built-in mechanism for raising exceptions. The `fail!()` macro
@@ -363,8 +410,8 @@ either task fails, it kills the other one.
363410
~~~
364411
# fn sleep_forever() { loop { task::yield() } }
365412
# do task::try {
366-
do task::spawn {
367-
do task::spawn {
413+
do spawn {
414+
do spawn {
368415
fail!(); // All three tasks will fail.
369416
}
370417
sleep_forever(); // Will get woken up by force, then fail

trunk/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ struct TimeBomb {
19771977
19781978
impl Drop for TimeBomb {
19791979
fn finalize(&self) {
1980-
for old_iter::repeat(self.explosivity) {
1980+
for self.explosivity.times {
19811981
println("blam!");
19821982
}
19831983
}

trunk/mk/platform.mk

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,32 @@ CFG_RUN_arm-linux-androideabi=
239239
CFG_RUN_TARG_arm-linux-androideabi=
240240
RUSTC_FLAGS_arm-linux-androideabi :=--android-cross-path=$(CFG_ANDROID_CROSS_PATH)
241241

242+
# arm-unknown-linux-gnueabihf configuration
243+
CC_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-gcc
244+
CXX_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-g++
245+
CPP_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-gcc -E
246+
AR_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-ar
247+
CFG_LIB_NAME_arm-unknown-linux-gnueabihf=lib$(1).so
248+
CFG_LIB_GLOB_arm-unknown-linux-gnueabihf=lib$(1)-*.so
249+
CFG_LIB_DSYM_GLOB_arm-unknown-linux-gnueabihf=lib$(1)-*.dylib.dSYM
250+
CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabihf := -Wall -g -fPIC
251+
CFG_GCCISH_CXXFLAGS_arm-unknown-linux-gnueabihf := -fno-rtti
252+
CFG_GCCISH_LINK_FLAGS_arm-unknown-linux-gnueabihf := -shared -fPIC -g
253+
CFG_GCCISH_DEF_FLAG_arm-unknown-linux-gnueabihf := -Wl,--export-dynamic,--dynamic-list=
254+
CFG_GCCISH_PRE_LIB_FLAGS_arm-unknown-linux-gnueabihf := -Wl,-whole-archive
255+
CFG_GCCISH_POST_LIB_FLAGS_arm-unknown-linux-gnueabihf := -Wl,-no-whole-archive
256+
CFG_DEF_SUFFIX_arm-unknown-linux-gnueabihf := .linux.def
257+
CFG_INSTALL_NAME_ar,-unknown-linux-gnueabihf =
258+
CFG_LIBUV_LINK_FLAGS_arm-unknown-linux-gnueabihf =
259+
CFG_EXE_SUFFIX_arm-unknown-linux-gnueabihf :=
260+
CFG_WINDOWSY_arm-unknown-linux-gnueabihf :=
261+
CFG_UNIXY_arm-unknown-linux-gnueabihf := 1
262+
CFG_PATH_MUNGE_arm-unknown-linux-gnueabihf := true
263+
CFG_LDPATH_arm-unknown-linux-gnueabihf :=
264+
CFG_RUN_arm-unknown-linux-gnueabihf=
265+
CFG_RUN_TARG_arm-unknown-linux-gnueabihf=
266+
RUSTC_FLAGS_arm-unknown-linux-gnueabihf := --linker=$(CC_arm-unknown-linux-gnueabihf)
267+
242268
# mips-unknown-linux-gnu configuration
243269
CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
244270
CXX_mips-unknown-linux-gnu=mips-linux-gnu-g++

trunk/mk/rt.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
# Hack for passing flags into LIBUV, see below.
2727
LIBUV_FLAGS_i386 = -m32 -fPIC
2828
LIBUV_FLAGS_x86_64 = -m64 -fPIC
29+
ifeq ($(OSTYPE_$(1)), linux-androideabi)
2930
LIBUV_FLAGS_arm = -fPIC -DANDROID -std=gnu99
31+
else
32+
LIBUV_FLAGS_arm = -fPIC -std=gnu99
33+
endif
3034
LIBUV_FLAGS_mips = -fPIC -mips32r2 -msoft-float -mabi=32
3135

3236
# when we're doing a snapshot build, we intentionally degrade as many

trunk/src/compiletest/compiletest.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#[allow(non_camel_case_types)];
1414

15-
extern mod std(vers = "0.7-pre");
15+
extern mod std;
1616

1717
use core::*;
1818

trunk/src/driver/driver.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
// except according to those terms.
1010

1111
#[cfg(rustpkg)]
12-
extern mod this(name = "rustpkg", vers = "0.7-pre");
12+
extern mod this(name = "rustpkg");
1313

1414
#[cfg(fuzzer)]
15-
extern mod this(name = "fuzzer", vers = "0.7-pre");
15+
extern mod this(name = "fuzzer");
1616

1717
#[cfg(rustdoc)]
18-
extern mod this(name = "rustdoc", vers = "0.7-pre");
18+
extern mod this(name = "rustdoc");
1919

2020
#[cfg(rusti)]
21-
extern mod this(name = "rusti", vers = "0.7-pre");
21+
extern mod this(name = "rusti");
2222

2323
#[cfg(rust)]
24-
extern mod this(name = "rust", vers = "0.7-pre");
24+
extern mod this(name = "rust");
2525

2626
#[cfg(rustc)]
27-
extern mod this(name = "rustc", vers = "0.7-pre");
27+
extern mod this(name = "rustc");
2828

2929
fn main() { this::main() }

trunk/src/libcore/at_vec.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,30 +294,30 @@ mod test {
294294
}
295295

296296
assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]);
297-
assert!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
298-
assert!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
297+
assert_eq!(from_fn(5, |x| x+1), @[1, 2, 3, 4, 5]);
298+
assert_eq!(from_elem(5, 3.14), @[3.14, 3.14, 3.14, 3.14, 3.14]);
299299
}
300300

301301
#[test]
302302
fn append_test() {
303-
assert!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]);
303+
assert_eq!(@[1,2,3] + @[4,5,6], @[1,2,3,4,5,6]);
304304
}
305305

306306
#[test]
307307
fn test_to_managed_consume() {
308-
assert!(to_managed_consume::<int>(~[]) == @[]);
309-
assert!(to_managed_consume(~[true]) == @[true]);
310-
assert!(to_managed_consume(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
311-
assert!(to_managed_consume(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
312-
assert!(to_managed_consume(~[~[42]]) == @[~[42]]);
308+
assert_eq!(to_managed_consume::<int>(~[]), @[]);
309+
assert_eq!(to_managed_consume(~[true]), @[true]);
310+
assert_eq!(to_managed_consume(~[1, 2, 3, 4, 5]), @[1, 2, 3, 4, 5]);
311+
assert_eq!(to_managed_consume(~[~"abc", ~"123"]), @[~"abc", ~"123"]);
312+
assert_eq!(to_managed_consume(~[~[42]]), @[~[42]]);
313313
}
314314
315315
#[test]
316316
fn test_to_managed() {
317-
assert!(to_managed::<int>([]) == @[]);
318-
assert!(to_managed([true]) == @[true]);
319-
assert!(to_managed([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
320-
assert!(to_managed([@"abc", @"123"]) == @[@"abc", @"123"]);
321-
assert!(to_managed([@[42]]) == @[@[42]]);
317+
assert_eq!(to_managed::<int>([]), @[]);
318+
assert_eq!(to_managed([true]), @[true]);
319+
assert_eq!(to_managed([1, 2, 3, 4, 5]), @[1, 2, 3, 4, 5]);
320+
assert_eq!(to_managed([@"abc", @"123"]), @[@"abc", @"123"]);
321+
assert_eq!(to_managed([@[42]]), @[@[42]]);
322322
}
323323
}

trunk/src/libcore/bool.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ pub fn is_false(v: bool) -> bool { !v }
4949
/// Parse logic value from `s`
5050
impl FromStr for bool {
5151
fn from_str(s: &str) -> Option<bool> {
52-
if s == "true" {
53-
Some(true)
54-
} else if s == "false" {
55-
Some(false)
56-
} else {
57-
None
52+
match s {
53+
"true" => Some(true),
54+
"false" => Some(false),
55+
_ => None,
5856
}
5957
}
6058
}
@@ -115,14 +113,14 @@ mod tests {
115113

116114
#[test]
117115
fn test_bool_to_str() {
118-
assert!(to_str(false) == ~"false");
119-
assert!(to_str(true) == ~"true");
116+
assert_eq!(to_str(false), ~"false");
117+
assert_eq!(to_str(true), ~"true");
120118
}
121119

122120
#[test]
123121
fn test_bool_to_bit() {
124122
do all_values |v| {
125-
assert!(to_bit(v) == if is_true(v) { 1u8 } else { 0u8 });
123+
assert_eq!(to_bit(v), if is_true(v) { 1u8 } else { 0u8 });
126124
}
127125
}
128126

trunk/src/libcore/cast.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,6 @@ pub mod rusti {
2424
}
2525

2626
/// Casts the value at `src` to U. The two types must have the same length.
27-
#[cfg(not(stage0))]
28-
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
29-
let mut dest: U = unstable::intrinsics::uninit();
30-
{
31-
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
32-
let src_ptr: *u8 = rusti::transmute(src);
33-
unstable::intrinsics::memmove64(dest_ptr,
34-
src_ptr,
35-
sys::size_of::<U>() as u64);
36-
}
37-
dest
38-
}
39-
40-
#[cfg(stage0)]
4127
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
4228
let mut dest: U = unstable::intrinsics::init();
4329
{
@@ -145,7 +131,7 @@ mod tests {
145131

146132
#[test]
147133
fn test_transmute_copy() {
148-
assert!(1u == unsafe { ::cast::transmute_copy(&1) });
134+
assert_eq!(1u, unsafe { ::cast::transmute_copy(&1) });
149135
}
150136

151137
#[test]
@@ -177,7 +163,7 @@ mod tests {
177163
#[test]
178164
fn test_transmute2() {
179165
unsafe {
180-
assert!(~[76u8, 0u8] == transmute(~"L"));
166+
assert_eq!(~[76u8, 0u8], transmute(~"L"));
181167
}
182168
}
183169
}

trunk/src/libcore/cell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn test_with_ref() {
122122
let good = 6;
123123
let c = Cell(~[1, 2, 3, 4, 5, 6]);
124124
let l = do c.with_ref() |v| { v.len() };
125-
assert!(l == good);
125+
assert_eq!(l, good);
126126
}
127127

128128
#[test]
@@ -132,5 +132,5 @@ fn test_with_mut_ref() {
132132
let c = Cell(v);
133133
do c.with_mut_ref() |v| { v.push(3); }
134134
let v = c.take();
135-
assert!(v == good);
135+
assert_eq!(v, good);
136136
}

0 commit comments

Comments
 (0)