Skip to content

Commit 1c6db4c

Browse files
committed
---
yaml --- r: 151330 b: refs/heads/try2 c: 6201d6d h: refs/heads/master v: v3
1 parent 5f02f0d commit 1c6db4c

Some content is hidden

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

51 files changed

+334
-1601
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: cba66bc9209ea2acbd51cabb9059f26a0416b2ec
8+
refs/heads/try2: 6201d6d0d94999d5e569f1d942920c2295e5682a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ documentation.
2020
## Building from Source
2121

2222
1. Make sure you have installed the dependencies:
23-
* `g++` 4.7 or `clang++` 3.x
23+
* `g++` 4.4 or `clang++` 3.x
2424
* `python` 2.6 or later (but not 3.x)
2525
* `perl` 5.0 or later
2626
* GNU `make` 3.81 or later

branches/try2/mk/crates.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
5353
uuid serialize sync getopts collections num test time rand \
54-
workcache url log regex graphviz
54+
workcache url log regex
5555
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros
5656
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5757
TOOLS := compiletest rustdoc rustc
@@ -67,7 +67,6 @@ DEPS_rustdoc := rustc native:sundown serialize sync getopts collections \
6767
test time
6868
DEPS_flate := std native:miniz
6969
DEPS_arena := std collections
70-
DEPS_graphviz := std
7170
DEPS_glob := std
7271
DEPS_serialize := std collections log
7372
DEPS_term := std collections

branches/try2/src/doc/guide-tasks.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ concurrency at this writing:
4848
* [`std::task`] - All code relating to tasks and task scheduling,
4949
* [`std::comm`] - The message passing interface,
5050
* [`sync::DuplexStream`] - An extension of `pipes::stream` that allows both sending and receiving,
51+
* [`sync::SyncSender`] - An extension of `pipes::stream` that provides synchronous message sending,
52+
* [`sync::SyncReceiver`] - An extension of `pipes::stream` that acknowledges each message received,
53+
* [`sync::rendezvous`] - Creates a stream whose channel, upon sending a message, blocks until the
54+
message is received.
5155
* [`sync::Arc`] - The Arc (atomically reference counted) type, for safely sharing immutable data,
56+
* [`sync::RWArc`] - A dual-mode Arc protected by a reader-writer lock,
57+
* [`sync::MutexArc`] - An Arc with mutable data protected by a blocking mutex,
5258
* [`sync::Semaphore`] - A counting, blocking, bounded-waiting semaphore,
5359
* [`sync::Mutex`] - A blocking, bounded-waiting, mutual exclusion lock with an associated
5460
FIFO condition variable,
@@ -64,8 +70,13 @@ concurrency at this writing:
6470
[`std::task`]: std/task/index.html
6571
[`std::comm`]: std/comm/index.html
6672
[`sync::DuplexStream`]: sync/struct.DuplexStream.html
73+
[`sync::SyncSender`]: sync/struct.SyncSender.html
74+
[`sync::SyncReceiver`]: sync/struct.SyncReceiver.html
75+
[`sync::rendezvous`]: sync/fn.rendezvous.html
6776
[`sync::Arc`]: sync/struct.Arc.html
68-
[`sync::Semaphore`]: sync/raw/struct.Semaphore.html
77+
[`sync::RWArc`]: sync/struct.RWArc.html
78+
[`sync::MutexArc`]: sync/struct.MutexArc.html
79+
[`sync::Semaphore`]: sync/struct.Semaphore.html
6980
[`sync::Mutex`]: sync/struct.Mutex.html
7081
[`sync::RWLock`]: sync/struct.RWLock.html
7182
[`sync::Barrier`]: sync/struct.Barrier.html
@@ -89,10 +100,7 @@ closure in the new task.
89100
fn print_message() { println!("I am running in a different task!"); }
90101
spawn(print_message);
91102
92-
// Print something profound in a different task using a `proc` expression
93-
// The `proc` expression evaluates to an (unnamed) owned closure.
94-
// That closure will call `println!(...)` when the spawned task runs.
95-
103+
// Print something more profound in a different task using a lambda expression
96104
spawn(proc() println!("I am also running in a different task!") );
97105
~~~~
98106

branches/try2/src/doc/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ fn main() {
370370
```
371371

372372
This example is starting to get more subtle,
373-
but it hints at the powerful compositionality of Rust's concurrent types.
373+
but it hints at the powerful composability of Rust's concurrent types.
374374
This time we've put our array of numbers inside a `Mutex` and then put *that* inside the `Arc`.
375375
Like immutable data,
376376
`Mutex`es are sharable,

branches/try2/src/doc/tutorial.md

Lines changed: 33 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ supported build environments that are most likely to work.
9090
To build from source you will also need the following prerequisite
9191
packages:
9292

93-
* g++ 4.7 or clang++ 3.x
93+
* g++ 4.4 or clang++ 3.x
9494
* python 2.6 or later (but not 3.x)
9595
* perl 5.0 or later
9696
* gnu make 3.81 or later
@@ -468,16 +468,19 @@ Unlike in C, there is no "falling through" between arms: only one arm
468468
executes, and it doesn't have to explicitly `break` out of the
469469
construct when it is finished.
470470

471-
A `match` arm consists of a *pattern*, then a fat arrow `=>`, followed
472-
by an *action* (expression). Each case is separated by commas. It is
473-
often convenient to use a block expression for each case, in which case
474-
the commas are optional as shown below. Literals are valid patterns and
475-
match only their own value. A single arm may match multiple different
476-
patterns by combining them with the pipe operator (`|`), so long as every
477-
pattern binds the same set of variables. Ranges of numeric literal
478-
patterns can be expressed with two dots, as in `M..N`. The underscore
479-
(`_`) is a wildcard pattern that matches any single value. (`..`) is a
480-
different wildcard that can match one or more fields in an `enum` variant.
471+
A `match` arm consists of a *pattern*, then an arrow `=>`, followed by
472+
an *action* (expression). Literals are valid patterns and match only
473+
their own value. A single arm may match multiple different patterns by
474+
combining them with the pipe operator (`|`), so long as every pattern
475+
binds the same set of variables. Ranges of numeric literal patterns
476+
can be expressed with two dots, as in `M..N`. The underscore (`_`) is
477+
a wildcard pattern that matches any single value. (`..`) is a different
478+
wildcard that can match one or more fields in an `enum` variant.
479+
480+
The patterns in a match arm are followed by a fat arrow, `=>`, then an
481+
expression to evaluate. Each case is separated by commas. It's often
482+
convenient to use a block expression for each case, in which case the
483+
commas are optional.
481484

482485
~~~
483486
# let my_number = 1;
@@ -1413,7 +1416,7 @@ contains a point, but allocated in a different location:
14131416
14141417
~~~
14151418
# struct Point { x: f64, y: f64 }
1416-
let on_the_stack : Point = Point { x: 3.0, y: 4.0 };
1419+
let on_the_stack : Point = Point { x: 3.0, y: 4.0 };
14171420
let owned_box : ~Point = ~Point { x: 7.0, y: 9.0 };
14181421
~~~
14191422
@@ -1717,103 +1720,38 @@ environment (sometimes referred to as "capturing" variables in their
17171720
environment). For example, you couldn't write the following:
17181721
17191722
~~~~ {.ignore}
1720-
let x = 3;
1723+
let foo = 10;
17211724
1722-
// `fun` cannot refer to `x`
1723-
fn fun() -> () { println!("{}", x); }
1725+
fn bar() -> int {
1726+
return foo; // `bar` cannot refer to `foo`
1727+
}
17241728
~~~~
17251729
1726-
A _closure_ does support accessing the enclosing scope; below we will create
1727-
2 _closures_ (nameless functions). Compare how `||` replaces `()` and how
1728-
they try to access `x`:
1729-
1730-
~~~~ {.ignore}
1731-
let x = 3;
1730+
Rust also supports _closures_, functions that can access variables in
1731+
the enclosing scope.
17321732
1733-
// `fun` is an invalid definition
1734-
fn fun () -> () { println!("{}", x) } // cannot capture from enclosing scope
1735-
let closure = || -> () { println!("{}", x) }; // can capture from enclosing scope
1736-
1737-
// `fun_arg` is an invalid definition
1738-
fn fun_arg (arg: int) -> () { println!("{}", arg + x) } // cannot capture
1739-
let closure_arg = |arg: int| -> () { println!("{}", arg + x) }; // can capture
1740-
// ^
1741-
// Requires a type because the implementation needs to know which `+` to use.
1742-
// In the future, the implementation may not need the help.
1733+
~~~~
1734+
fn call_closure_with_ten(b: |int|) { b(10); }
17431735
1744-
fun(); // Still won't work
1745-
closure(); // Prints: 3
1736+
let captured_var = 20;
1737+
let closure = |arg| println!("captured_var={}, arg={}", captured_var, arg);
17461738
1747-
fun_arg(7); // Still won't work
1748-
closure_arg(7); // Prints: 10
1739+
call_closure_with_ten(closure);
17491740
~~~~
17501741
17511742
Closures begin with the argument list between vertical bars and are followed by
17521743
a single expression. Remember that a block, `{ <expr1>; <expr2>; ... }`, is
17531744
considered a single expression: it evaluates to the result of the last
17541745
expression it contains if that expression is not followed by a semicolon,
1755-
otherwise the block evaluates to `()`, the unit value.
1756-
1757-
In general, return types and all argument types must be specified
1758-
explicitly for function definitions. (As previously mentioned in the
1759-
[Functions section](#functions), omitting the return type from a
1760-
function declaration is synonymous with an explicit declaration of
1761-
return type unit, `()`.)
1746+
otherwise the block evaluates to `()`.
17621747
1763-
~~~~ {.ignore}
1764-
fn fun (x: int) { println!("{}", x) } // this is same as saying `-> ()`
1765-
fn square(x: int) -> uint { (x * x) as uint } // other return types are explicit
1748+
The types of the arguments are generally omitted, as is the return type,
1749+
because the compiler can almost always infer them. In the rare case where the
1750+
compiler needs assistance, though, the arguments and return types may be
1751+
annotated.
17661752
1767-
// Error: mismatched types: expected `()` but found `uint`
1768-
fn badfun(x: int) { (x * x) as uint }
17691753
~~~~
1770-
1771-
On the other hand, the compiler can usually infer both the argument
1772-
and return types for a closure expression; therefore they are often
1773-
omitted, since both a human reader and the compiler can deduce the
1774-
types from the immediate context. This is in contrast to function
1775-
declarations, which require types to be specified and are not subject
1776-
to type inference. Compare:
1777-
1778-
~~~~ {.ignore}
1779-
// `fun` as a function declaration cannot infer the type of `x`, so it must be provided
1780-
fn fun (x: int) { println!("{}", x) }
1781-
let closure = |x | { println!("{}", x) }; // infers `x: int`, return type `()`
1782-
1783-
// For closures, omitting a return type is *not* synonymous with `-> ()`
1784-
let add_3 = |y | { 3i + y }; // infers `y: int`, return type `int`.
1785-
1786-
fun(10); // Prints 10
1787-
closure(20); // Prints 20
1788-
closure(add_3(30)); // Prints 33
1789-
1790-
fun("String"); // Error: mismatched types
1791-
1792-
// Error: mismatched types
1793-
// inference already assigned `closure` the type `|int| -> ()`
1794-
closure("String");
1795-
~~~~
1796-
1797-
In cases where the compiler needs assistance, the arguments and return
1798-
types may be annotated on closures, using the same notation as shown
1799-
earlier. In the example below, since different types provide an
1800-
implementation for the operator `*`, the argument type for the `x`
1801-
parameter must be explicitly provided.
1802-
1803-
~~~~{.ignore}
1804-
// Error: the type of `x` must be known to be used with `x * x`
1805-
let square = |x | -> uint { (x * x) as uint };
1806-
~~~~
1807-
1808-
In the corrected version, the argument type is explicitly annotated,
1809-
while the return type can still be inferred.
1810-
1811-
~~~~
1812-
let square_explicit = |x: int| -> uint { (x * x) as uint };
1813-
let square_infer = |x: int| { (x * x) as uint };
1814-
1815-
println!("{}", square_explicit(20)); // 400
1816-
println!("{}", square_infer(-20)); // 400
1754+
let square = |x: int| -> uint { (x * x) as uint };
18171755
~~~~
18181756
18191757
There are several forms of closure, each with its own role. The most
@@ -2584,18 +2522,11 @@ for `Eq` and can be used with the equality operators, and that a value
25842522
of type `ABC` can be randomly generated and converted to a string:
25852523

25862524
~~~
2587-
extern crate rand;
2588-
25892525
#[deriving(Eq)]
25902526
struct Circle { radius: f64 }
25912527
2592-
#[deriving(Rand, Show)]
2528+
#[deriving(Clone, Show)]
25932529
enum ABC { A, B, C }
2594-
2595-
fn main() {
2596-
// Use the Show trait to print "A, B, C."
2597-
println!("{}, {}, {}", A, B, C);
2598-
}
25992530
~~~
26002531

26012532
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,

branches/try2/src/etc/emacs/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ To install manually, check out this repository and add this to your
1212

1313
```lisp
1414
(add-to-list 'load-path "/path/to/rust-mode/")
15-
(autoload 'rust-mode "rust-mode" nil t)
16-
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
15+
(require 'rust-mode)
1716
```
1817

19-
This associates `rust-mode` with `.rs` files. To enable it explicitly, do
20-
<kbd>M-x rust-mode</kbd>.
18+
`rust-mode` will automatically be associated with `.rs` files. To enable it
19+
explicitly, do <kbd>M-x rust-mode</kbd>.
2120

2221
### `package.el` installation via Marmalade or MELPA
2322

branches/try2/src/etc/vim/indent/rust.vim

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ endif
3030

3131
" Come here when loading the script the first time.
3232

33-
function! s:get_line_trimmed(lnum)
33+
function s:get_line_trimmed(lnum)
3434
" Get the line and remove a trailing comment.
3535
" Use syntax highlighting attributes when possible.
3636
" NOTE: this is not accurate; /* */ or a line continuation could trick it
@@ -61,20 +61,6 @@ function! s:get_line_trimmed(lnum)
6161
endif
6262
endfunction
6363

64-
function! s:is_string_comment(lnum, col)
65-
if has('syntax_items')
66-
for id in synstack(a:lnum, a:col)
67-
let synname = synIDattr(id, "name")
68-
if synname == "rustString" || synname =~ "^rustComment"
69-
return 1
70-
endif
71-
endfor
72-
else
73-
" without syntax, let's not even try
74-
return 0
75-
endif
76-
endfunction
77-
7864
function GetRustIndent(lnum)
7965

8066
" Starting assumption: cindent (called at the end) will do it right
@@ -166,10 +152,8 @@ function GetRustIndent(lnum)
166152
" column zero)
167153

168154
call cursor(a:lnum, 1)
169-
if searchpair('{\|(', '', '}\|)', 'nbW'
170-
\ 's:is_string_comment(line("."), col("."))') == 0
171-
if searchpair('\[', '', '\]', 'nbW',
172-
\ 's:is_string_comment(line("."), col("."))') == 0
155+
if searchpair('{\|(', '', '}\|)', 'nbW') == 0
156+
if searchpair('\[', '', '\]', 'nbW') == 0
173157
" Global scope, should be zero
174158
return 0
175159
else

branches/try2/src/libarena/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
extern crate collections;
2828

29-
use std::cast::{transmute, transmute_mut_lifetime};
29+
use std::cast::{transmute, transmute_mut, transmute_mut_lifetime};
3030
use std::cast;
3131
use std::cell::{Cell, RefCell};
3232
use std::mem;
@@ -281,8 +281,8 @@ impl Arena {
281281
#[inline]
282282
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
283283
unsafe {
284-
// FIXME #13933: Remove/justify all `&T` to `&mut T` transmutes
285-
let this: &mut Arena = transmute::<&_, &mut _>(self);
284+
// FIXME: Borrow check
285+
let this = transmute_mut(self);
286286
if intrinsics::needs_drop::<T>() {
287287
this.alloc_noncopy(op)
288288
} else {
@@ -438,8 +438,7 @@ impl<T> TypedArena<T> {
438438
#[inline]
439439
pub fn alloc<'a>(&'a self, object: T) -> &'a T {
440440
unsafe {
441-
// FIXME #13933: Remove/justify all `&T` to `&mut T` transmutes
442-
let this: &mut TypedArena<T> = cast::transmute::<&_, &mut _>(self);
441+
let this = cast::transmute_mut(self);
443442
if this.ptr == this.end {
444443
this.grow()
445444
}

0 commit comments

Comments
 (0)