Skip to content

Commit b7589d1

Browse files
committed
---
yaml --- r: 35977 b: refs/heads/try2 c: 32baf1c h: refs/heads/master i: 35975: 077de2d v: v3
1 parent 4a03a80 commit b7589d1

File tree

280 files changed

+3658
-4217
lines changed

Some content is hidden

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

280 files changed

+3658
-4217
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: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b532a8e5856d525bb7121f4bc00603b91bc2cc5d
8+
refs/heads/try2: 32baf1c54c4214f5a50da53979008ef9bcdad359
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/doc/tutorial-tasks.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ use pipes::{stream, Port, Chan};
161161
162162
let (chan, port): (Chan<int>, Port<int>) = stream();
163163
164-
do spawn |move chan| {
164+
do spawn {
165165
let result = some_expensive_computation();
166166
chan.send(result);
167167
}
@@ -192,7 +192,7 @@ spawns the child task.
192192
# use pipes::{stream, Port, Chan};
193193
# fn some_expensive_computation() -> int { 42 }
194194
# let (chan, port) = stream();
195-
do spawn |move chan| {
195+
do spawn {
196196
let result = some_expensive_computation();
197197
chan.send(result);
198198
}
@@ -229,7 +229,7 @@ following program is ill-typed:
229229
# fn some_expensive_computation() -> int { 42 }
230230
let (chan, port) = stream();
231231
232-
do spawn |move chan| {
232+
do spawn {
233233
chan.send(some_expensive_computation());
234234
}
235235
@@ -253,7 +253,7 @@ let chan = SharedChan(move chan);
253253
for uint::range(0, 3) |init_val| {
254254
// Create a new channel handle to distribute to the child task
255255
let child_chan = chan.clone();
256-
do spawn |move child_chan| {
256+
do spawn {
257257
child_chan.send(some_expensive_computation(init_val));
258258
}
259259
}
@@ -283,10 +283,10 @@ might look like the example below.
283283
// Create a vector of ports, one for each child task
284284
let ports = do vec::from_fn(3) |init_val| {
285285
let (chan, port) = stream();
286-
do spawn |move chan| {
286+
do spawn {
287287
chan.send(some_expensive_computation(init_val));
288288
}
289-
move port
289+
port
290290
};
291291
292292
// Wait on each port, accumulating the results
@@ -398,13 +398,13 @@ before returning. Hence:
398398
# fn sleep_forever() { loop { task::yield() } }
399399
# do task::try {
400400
let (sender, receiver): (Chan<int>, Port<int>) = stream();
401-
do spawn |move receiver| { // Bidirectionally linked
401+
do spawn { // Bidirectionally linked
402402
// Wait for the supervised child task to exist.
403403
let message = receiver.recv();
404404
// Kill both it and the parent task.
405405
assert message != 42;
406406
}
407-
do try |move sender| { // Unidirectionally linked
407+
do try { // Unidirectionally linked
408408
sender.send(42);
409409
sleep_forever(); // Will get woken up by force
410410
}
@@ -505,7 +505,7 @@ Here is the code for the parent task:
505505
506506
let (from_child, to_child) = DuplexStream();
507507
508-
do spawn |move to_child| {
508+
do spawn || {
509509
stringifier(&to_child);
510510
};
511511

branches/try2/doc/tutorial.md

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,9 +1502,9 @@ and [`core::str`]. Here are some examples.
15021502
# fn unwrap_crayon(c: Crayon) -> int { 0 }
15031503
# fn eat_crayon_wax(i: int) { }
15041504
# fn store_crayon_in_nasal_cavity(i: uint, c: Crayon) { }
1505-
# fn crayon_to_str(c: Crayon) -> &str { "" }
1505+
# fn crayon_to_str(c: Crayon) -> ~str { ~"" }
15061506
1507-
let crayons = [Almond, AntiqueBrass, Apricot];
1507+
let crayons = &[Almond, AntiqueBrass, Apricot];
15081508
15091509
// Check the length of the vector
15101510
assert crayons.len() == 3;
@@ -1569,7 +1569,7 @@ let bloop = |well, oh: mygoodness| -> what_the { fail oh(well) };
15691569
~~~~
15701570

15711571
There are several forms of closure, each with its own role. The most
1572-
common, called a _stack closure_, has type `&fn` and can directly
1572+
common, called a _stack closure_, has type `fn&` and can directly
15731573
access local variables in the enclosing scope.
15741574

15751575
~~~~
@@ -1591,7 +1591,7 @@ pervasively in Rust code.
15911591
When you need to store a closure in a data structure, a stack closure
15921592
will not do, since the compiler will refuse to let you store it. For
15931593
this purpose, Rust provides a type of closure that has an arbitrary
1594-
lifetime, written `@fn` (boxed closure, analogous to the `@` pointer
1594+
lifetime, written `fn@` (boxed closure, analogous to the `@` pointer
15951595
type described earlier). This type of closure *is* first-class.
15961596

15971597
A managed closure does not directly access its environment, but merely
@@ -1604,9 +1604,8 @@ returns it from a function, and then calls it:
16041604

16051605
~~~~
16061606
# extern mod std;
1607-
fn mk_appender(suffix: ~str) -> @fn(~str) -> ~str {
1608-
// The compiler knows that we intend this closure to be of type @fn
1609-
return |s| s + suffix;
1607+
fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str {
1608+
return fn@(s: ~str) -> ~str { s + suffix };
16101609
}
16111610
16121611
fn main() {
@@ -1615,9 +1614,22 @@ fn main() {
16151614
}
16161615
~~~~
16171616

1617+
This example uses the long closure syntax, `fn@(s: ~str) ...`. Using
1618+
this syntax makes it explicit that we are declaring a boxed
1619+
closure. In practice, boxed closures are usually defined with the
1620+
short closure syntax introduced earlier, in which case the compiler
1621+
infers the type of closure. Thus our managed closure example could
1622+
also be written:
1623+
1624+
~~~~
1625+
fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str {
1626+
return |s| s + suffix;
1627+
}
1628+
~~~~
1629+
16181630
## Owned closures
16191631

1620-
Owned closures, written `~fn` in analogy to the `~` pointer type,
1632+
Owned closures, written `fn~` in analogy to the `~` pointer type,
16211633
hold on to things that can safely be sent between
16221634
processes. They copy the values they close over, much like managed
16231635
closures, but they also own them: that is, no other code can access
@@ -1637,10 +1649,12 @@ callers may pass any kind of closure.
16371649

16381650
~~~~
16391651
fn call_twice(f: fn()) { f(); f(); }
1640-
let closure = || { "I'm a closure, and it doesn't matter what type I am"; };
1641-
fn function() { "I'm a normal function"; }
1642-
call_twice(closure);
1643-
call_twice(function);
1652+
call_twice(|| { ~"I am an inferred stack closure"; } );
1653+
call_twice(fn&() { ~"I am also a stack closure"; } );
1654+
call_twice(fn@() { ~"I am a managed closure"; });
1655+
call_twice(fn~() { ~"I am an owned closure"; });
1656+
fn bare_function() { ~"I am a plain function"; }
1657+
call_twice(bare_function);
16441658
~~~~
16451659

16461660
> ***Note:*** Both the syntax and the semantics will be changing
@@ -1679,7 +1693,7 @@ structure.
16791693
~~~~
16801694
# fn each(v: &[int], op: fn(v: &int)) { }
16811695
# fn do_some_work(i: &int) { }
1682-
each([1, 2, 3], |n| {
1696+
each(&[1, 2, 3], |n| {
16831697
do_some_work(n);
16841698
});
16851699
~~~~
@@ -1690,7 +1704,7 @@ call that can be written more like a built-in control structure:
16901704
~~~~
16911705
# fn each(v: &[int], op: fn(v: &int)) { }
16921706
# fn do_some_work(i: &int) { }
1693-
do each([1, 2, 3]) |n| {
1707+
do each(&[1, 2, 3]) |n| {
16941708
do_some_work(n);
16951709
}
16961710
~~~~
@@ -1701,7 +1715,7 @@ parentheses, where it looks more like a typical block of
17011715
code.
17021716

17031717
`do` is a convenient way to create tasks with the `task::spawn`
1704-
function. `spawn` has the signature `spawn(fn: ~fn())`. In other
1718+
function. `spawn` has the signature `spawn(fn: fn~())`. In other
17051719
words, it is a function that takes an owned closure that takes no
17061720
arguments.
17071721

@@ -1751,9 +1765,9 @@ And using this function to iterate over a vector:
17511765
~~~~
17521766
# use each = vec::each;
17531767
# use println = io::println;
1754-
each([2, 4, 8, 5, 16], |n| {
1768+
each(&[2, 4, 8, 5, 16], |n| {
17551769
if *n % 2 != 0 {
1756-
println("found odd number!");
1770+
println(~"found odd number!");
17571771
false
17581772
} else { true }
17591773
});
@@ -1768,9 +1782,9 @@ to the next iteration, write `loop`.
17681782
~~~~
17691783
# use each = vec::each;
17701784
# use println = io::println;
1771-
for each([2, 4, 8, 5, 16]) |n| {
1785+
for each(&[2, 4, 8, 5, 16]) |n| {
17721786
if *n % 2 != 0 {
1773-
println("found odd number!");
1787+
println(~"found odd number!");
17741788
break;
17751789
}
17761790
}
@@ -1813,7 +1827,7 @@ fn map<T, U>(vector: &[T], function: fn(v: &T) -> U) -> ~[U] {
18131827
for vec::each(vector) |element| {
18141828
accumulator.push(function(element));
18151829
}
1816-
return (move accumulator);
1830+
return accumulator;
18171831
}
18181832
~~~~
18191833

@@ -1953,12 +1967,12 @@ impl int: Printable {
19531967
fn print() { io::println(fmt!("%d", self)) }
19541968
}
19551969
1956-
impl &str: Printable {
1970+
impl ~str: Printable {
19571971
fn print() { io::println(self) }
19581972
}
19591973
19601974
# 1.print();
1961-
# ("foo").print();
1975+
# (~"foo").print();
19621976
~~~~
19631977

19641978
Methods defined in an implementation of a trait may be called just like
@@ -2106,7 +2120,7 @@ impl @Rectangle: Drawable { fn draw() { ... } }
21062120
21072121
let c: @Circle = @new_circle();
21082122
let r: @Rectangle = @new_rectangle();
2109-
draw_all([c as @Drawable, r as @Drawable]);
2123+
draw_all(&[c as @Drawable, r as @Drawable]);
21102124
~~~~
21112125

21122126
We omit the code for `new_circle` and `new_rectangle`; imagine that
@@ -2148,8 +2162,8 @@ additional modules.
21482162

21492163
~~~~
21502164
mod farm {
2151-
pub fn chicken() -> &str { "cluck cluck" }
2152-
pub fn cow() -> &str { "mooo" }
2165+
pub fn chicken() -> ~str { ~"cluck cluck" }
2166+
pub fn cow() -> ~str { ~"mooo" }
21532167
}
21542168
21552169
fn main() {
@@ -2346,13 +2360,13 @@ these two files:
23462360
~~~~
23472361
// world.rs
23482362
#[link(name = "world", vers = "1.0")];
2349-
pub fn explore() -> &str { "world" }
2363+
fn explore() -> ~str { ~"world" }
23502364
~~~~
23512365

23522366
~~~~ {.xfail-test}
23532367
// main.rs
23542368
extern mod world;
2355-
fn main() { io::println("hello " + world::explore()); }
2369+
fn main() { io::println(~"hello " + world::explore()); }
23562370
~~~~
23572371

23582372
Now compile and run like this (adjust to your platform if necessary):

branches/try2/src/cargo/cargo.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ fn configure(opts: Options) -> Cargo {
705705
~" or package manager to get it to work correctly");
706706
}
707707

708-
move c
708+
c
709709
}
710710

711711
fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) {
@@ -1162,20 +1162,20 @@ fn sync_one_file(c: &Cargo, dir: &Path, src: @Source) -> bool {
11621162
}
11631163
match (src.key, src.keyfp) {
11641164
(Some(_), Some(f)) => {
1165-
let r = pgp::verify(&c.root, &pkgfile, &sigfile);
1165+
let r = pgp::verify(&c.root, &pkgfile, &sigfile, f);
11661166

11671167
if !r {
1168-
error(fmt!("signature verification failed for source %s with key %s",
1169-
name, f));
1168+
error(fmt!("signature verification failed for source %s",
1169+
name));
11701170
return false;
11711171
}
11721172

11731173
if has_src_file {
1174-
let e = pgp::verify(&c.root, &srcfile, &srcsigfile);
1174+
let e = pgp::verify(&c.root, &srcfile, &srcsigfile, f);
11751175

11761176
if !e {
1177-
error(fmt!("signature verification failed for source %s with key %s",
1178-
name, f));
1177+
error(fmt!("signature verification failed for source %s",
1178+
name));
11791179
return false;
11801180
}
11811181
}
@@ -1273,21 +1273,21 @@ fn sync_one_git(c: &Cargo, dir: &Path, src: @Source) -> bool {
12731273
}
12741274
match (src.key, src.keyfp) {
12751275
(Some(_), Some(f)) => {
1276-
let r = pgp::verify(&c.root, &pkgfile, &sigfile);
1276+
let r = pgp::verify(&c.root, &pkgfile, &sigfile, f);
12771277

12781278
if !r {
1279-
error(fmt!("signature verification failed for source %s with key %s",
1280-
name, f));
1279+
error(fmt!("signature verification failed for source %s",
1280+
name));
12811281
rollback(name, dir, false);
12821282
return false;
12831283
}
12841284

12851285
if has_src_file {
1286-
let e = pgp::verify(&c.root, &srcfile, &srcsigfile);
1286+
let e = pgp::verify(&c.root, &srcfile, &srcsigfile, f);
12871287

12881288
if !e {
1289-
error(fmt!("signature verification failed for source %s with key %s",
1290-
name, f));
1289+
error(fmt!("signature verification failed for source %s",
1290+
name));
12911291
rollback(name, dir, false);
12921292
return false;
12931293
}
@@ -1370,11 +1370,11 @@ fn sync_one_curl(c: &Cargo, dir: &Path, src: @Source) -> bool {
13701370
return false;
13711371
}
13721372

1373-
let r = pgp::verify(&c.root, &pkgfile, &sigfile);
1373+
let r = pgp::verify(&c.root, &pkgfile, &sigfile, f);
13741374

13751375
if !r {
1376-
error(fmt!("signature verification failed for source %s with key %s",
1377-
name, f));
1376+
error(fmt!("signature verification failed for source %s",
1377+
name));
13781378
return false;
13791379
}
13801380

@@ -1390,11 +1390,11 @@ fn sync_one_curl(c: &Cargo, dir: &Path, src: @Source) -> bool {
13901390
return false;
13911391
}
13921392

1393-
let e = pgp::verify(&c.root, &srcfile, &srcsigfile);
1393+
let e = pgp::verify(&c.root, &srcfile, &srcsigfile, f);
13941394

13951395
if !e {
13961396
error(~"signature verification failed for " +
1397-
~"source " + name + ~" with key " + f);
1397+
~"source " + name);
13981398
return false;
13991399
}
14001400
}
@@ -1463,7 +1463,8 @@ fn cmd_init(c: &Cargo) {
14631463
return;
14641464
}
14651465

1466-
let r = pgp::verify(&c.root, &srcfile, &sigfile);
1466+
let r = pgp::verify(&c.root, &srcfile, &sigfile,
1467+
pgp::signing_key_fp());
14671468
if !r {
14681469
error(fmt!("signature verification failed for '%s'",
14691470
srcfile.to_str()));
@@ -1614,10 +1615,10 @@ fn dump_sources(c: &Cargo) {
16141615
_ => ()
16151616
}
16161617

1617-
hash.insert(copy k, json::Object(move chash));
1618+
hash.insert(copy k, json::Object(chash));
16181619
}
16191620

1620-
json::to_writer(writer, &json::Object(move hash))
1621+
json::to_writer(writer, &json::Object(hash))
16211622
}
16221623
result::Err(e) => {
16231624
error(fmt!("could not dump sources: %s", e));

0 commit comments

Comments
 (0)