Skip to content

Commit afdd9d0

Browse files
committed
---
yaml --- r: 151294 b: refs/heads/try2 c: 1b5bbbf h: refs/heads/master v: v3
1 parent 5d3bd5f commit afdd9d0

File tree

259 files changed

+4055
-3425
lines changed

Some content is hidden

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

259 files changed

+4055
-3425
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: 8375a22b16ae6d746ccfd1f725a26562f55a82ba
8+
refs/heads/try2: 1b5bbbf87792859c0f9bb797688259b19f626ab0
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/LICENSE-MIT

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Copyright (c) 2006-2009 Graydon Hoare
2-
Copyright (c) 2009-2014 Mozilla Foundation
1+
Copyright (c) 2014 The Rust Project Developers
32

43
Permission is hereby granted, free of charge, to any
54
person obtaining a copy of this software and associated

branches/try2/RELEASES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Version 0.10 (April 2014)
6363
documentation index page.
6464
* std: `std::condition` has been removed. All I/O errors are now propagated
6565
through the `Result` type. In order to assist with error handling, a
66-
`try!` macro for unwrapping errors with an early return and an lint for
66+
`try!` macro for unwrapping errors with an early return and a lint for
6767
unused results has been added. See #12039 for more information.
6868
* std: The `vec` module has been renamed to `slice`.
6969
* std: A new vector type, `Vec<T>`, has been added in preparation for DST.

branches/try2/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn parse_compile_flags(line: &str) -> Option<~str> {
170170
}
171171

172172
fn parse_run_flags(line: &str) -> Option<~str> {
173-
parse_name_value_directive(line, ~"run-flags")
173+
parse_name_value_directive(line, "run-flags".to_owned())
174174
}
175175

176176
fn parse_debugger_cmd(line: &str) -> Option<~str> {

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ differently.
120120
Containers implement iteration over the contained elements by returning an
121121
iterator object. For example, vector slices several iterators available:
122122
123-
* `iter()` and `rev_iter()`, for immutable references to the elements
124-
* `mut_iter()` and `mut_rev_iter()`, for mutable references to the elements
125-
* `move_iter()` and `move_rev_iter()`, to move the elements out by-value
123+
* `iter()` for immutable references to the elements
124+
* `mut_iter()` for mutable references to the elements
125+
* `move_iter()` to move the elements out by-value
126126
127127
A typical mutable container will implement at least `iter()`, `mut_iter()` and
128-
`move_iter()` along with the reverse variants if it maintains an order.
128+
`move_iter()`. If it maintains an order, the returned iterators will be
129+
`DoubleEndedIterator`s, which are described below.
129130
130131
### Freezing
131132
@@ -265,7 +266,7 @@ Iterators offer generic conversion to containers with the `collect` adaptor:
265266
266267
~~~
267268
let xs = [0, 1, 1, 2, 3, 5, 8];
268-
let ys = xs.rev_iter().skip(1).map(|&x| x * 2).collect::<~[int]>();
269+
let ys = xs.iter().rev().skip(1).map(|&x| x * 2).collect::<~[int]>();
269270
assert_eq!(ys, ~[10, 6, 4, 2, 2, 0]);
270271
~~~
271272
@@ -358,9 +359,6 @@ for &x in it.rev() {
358359
}
359360
~~~
360361

361-
The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted
362-
version of the standard immutable and mutable vector iterators.
363-
364362
The `chain`, `map`, `filter`, `filter_map` and `inspect` adaptors are
365363
`DoubleEndedIterator` implementations if the underlying iterators are.
366364

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ process is called *rooting*.
263263
The previous example demonstrated *rooting*, the process by which the
264264
compiler ensures that managed boxes remain live for the duration of a
265265
borrow. Unfortunately, rooting does not work for borrows of owned
266-
boxes, because it is not possible to have two references to a owned
266+
boxes, because it is not possible to have two references to an owned
267267
box.
268268

269269
For owned boxes, therefore, the compiler will only allow a borrow *if
@@ -462,7 +462,7 @@ of a `f64` as if it were a struct with two fields would be a memory
462462
safety violation.
463463

464464
So, in fact, for every `ref` binding, the compiler will impose the
465-
same rules as the ones we saw for borrowing the interior of a owned
465+
same rules as the ones we saw for borrowing the interior of an owned
466466
box: it must be able to guarantee that the `enum` will not be
467467
overwritten for the duration of the borrow. In fact, the compiler
468468
would accept the example we gave earlier. The example is safe because

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ enum List<T> {
186186
Nil,
187187
Cons(T, ~List<T>),
188188
}
189-
189+
190190
fn main() {
191191
let list: List<int> = Cons(1, ~Cons(2, ~Cons(3, ~Nil)));
192192
println!("{:?}", list);
@@ -251,7 +251,7 @@ struct.
251251

252252
> **Note**: the `@` form of managed pointers is deprecated and behind a
253253
> feature gate (it requires a `#![feature(managed_pointers)]` attribute on
254-
> the crate root; remember the semicolon!). There are replacements, currently
254+
> the crate root). There are replacements, currently
255255
> there is `std::rc::Rc` and `std::gc::Gc` for shared ownership via reference
256256
> counting and garbage collection respectively.
257257
@@ -266,7 +266,7 @@ struct Point {
266266
x: int,
267267
y: int,
268268
}
269-
269+
270270
fn main() {
271271
let a = ~Point { x: 10, y: 20 };
272272
let b = a;
@@ -297,7 +297,7 @@ struct Point {
297297
x: int,
298298
y: int,
299299
}
300-
300+
301301
fn main() {
302302
let a = @Point { x: 10, y: 20 };
303303
let b = a;
@@ -361,7 +361,7 @@ So how is this hard? Well, because we're ignoring ownership, the compiler needs
361361
to take great care to make sure that everything is safe. Despite their complete
362362
safety, a reference's representation at runtime is the same as that of
363363
an ordinary pointer in a C program. They introduce zero overhead. The compiler
364-
does all safety checks at compile time.
364+
does all safety checks at compile time.
365365

366366
This theory is called 'region pointers,' and involve a concept called
367367
'lifetimes'. Here's the simple explanation: would you expect this code to
@@ -477,7 +477,7 @@ fn main() {
477477
You may think that this gives us terrible performance: return a value and then
478478
immediately box it up?!?! Isn't that the worst of both worlds? Rust is smarter
479479
than that. There is no copy in this code. `main` allocates enough room for the
480-
`@int`, passes a pointer to that memory into `foo` as `x`, and then `foo` writes
480+
`@int`, passes a pointer to that memory into `foo` as `x`, and then `foo` writes
481481
the value straight into that pointer. This writes the return value directly into
482482
the allocated box.
483483

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ fn print_message() { println!("I am running in a different task!"); }
101101
spawn(print_message);
102102
103103
// Print something more profound in a different task using a lambda expression
104+
// This uses the proc() keyword to assign to spawn a function with no name
105+
// That function will call println!(...) as requested
104106
spawn(proc() println!("I am also running in a different task!") );
105107
~~~~
106108

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ standard library types, e.g. `Cell` and `RefCell`, that provide inner
5656
mutability by replacing compile time guarantees with dynamic checks at
5757
runtime.
5858

59-
An `&mut` reference has a stronger requirement: when a object has an
59+
An `&mut` reference has a stronger requirement: when an object has an
6060
`&mut T` pointing into it, then that `&mut` reference must be the only
6161
such usable path to that object in the whole program. That is, an
6262
`&mut` cannot alias with any other references.

branches/try2/src/doc/rust.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Comments in Rust code follow the general C++ style of line and block-comment for
161161
with no nesting of block-comment delimiters.
162162

163163
Line comments beginning with exactly _three_ slashes (`///`), and block
164-
comments beginning with a exactly one repeated asterisk in the block-open
164+
comments beginning with exactly one repeated asterisk in the block-open
165165
sequence (`/**`), are interpreted as a special syntax for `doc`
166166
[attributes](#attributes). That is, they are equivalent to writing
167167
`#[doc="..."]` around the body of the comment (this includes the comment
@@ -365,7 +365,7 @@ of integer literal suffix:
365365
give the literal the corresponding machine type.
366366

367367
The type of an _unsuffixed_ integer literal is determined by type inference.
368-
If a integer type can be _uniquely_ determined from the surrounding program
368+
If an integer type can be _uniquely_ determined from the surrounding program
369369
context, the unsuffixed integer literal has that type. If the program context
370370
underconstrains the type, the unsuffixed integer literal's type is `int`; if
371371
the program context overconstrains the type, it is considered a static type
@@ -2184,7 +2184,7 @@ Supported traits for `deriving` are:
21842184
* `Hash`, to iterate over the bytes in a data type.
21852185
* `Rand`, to create a random instance of a data type.
21862186
* `Default`, to create an empty instance of a data type.
2187-
* `Zero`, to create an zero instance of a numeric data type.
2187+
* `Zero`, to create a zero instance of a numeric data type.
21882188
* `FromPrimitive`, to create an instance from a numeric primitive.
21892189
* `Show`, to format a value using the `{}` formatter.
21902190

branches/try2/src/doc/tutorial.md

Lines changed: 87 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ fn eq(xs: &List, ys: &List) -> bool {
11971197
match (xs, ys) {
11981198
// If we have reached the end of both lists, they are equal.
11991199
(&Nil, &Nil) => true,
1200-
// If the current element in both lists is equal, keep going.
1200+
// If the current elements of both lists are equal, keep going.
12011201
(&Cons(x, ~ref next_xs), &Cons(y, ~ref next_ys))
12021202
if x == y => eq(next_xs, next_ys),
12031203
// If the current elements are not equal, the lists are not equal.
@@ -1304,7 +1304,7 @@ fn eq<T: Eq>(xs: &List<T>, ys: &List<T>) -> bool {
13041304
match (xs, ys) {
13051305
// If we have reached the end of both lists, they are equal.
13061306
(&Nil, &Nil) => true,
1307-
// If the current element in both lists is equal, keep going.
1307+
// If the current elements of both lists are equal, keep going.
13081308
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
13091309
if x == y => eq(next_xs, next_ys),
13101310
// If the current elements are not equal, the lists are not equal.
@@ -1333,7 +1333,7 @@ impl<T: Eq> Eq for List<T> {
13331333
match (self, ys) {
13341334
// If we have reached the end of both lists, they are equal.
13351335
(&Nil, &Nil) => true,
1336-
// If the current element in both lists is equal, keep going.
1336+
// If the current elements of both lists are equal, keep going.
13371337
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
13381338
if x == y => next_xs == next_ys,
13391339
// If the current elements are not equal, the lists are not equal.
@@ -1720,38 +1720,103 @@ environment (sometimes referred to as "capturing" variables in their
17201720
environment). For example, you couldn't write the following:
17211721
17221722
~~~~ {.ignore}
1723-
let foo = 10;
1723+
let x = 3;
17241724
1725-
fn bar() -> int {
1726-
return foo; // `bar` cannot refer to `foo`
1727-
}
1725+
// `fun` cannot refer to `x`
1726+
fn fun() -> () { println!("{}", x); }
17281727
~~~~
17291728
1730-
Rust also supports _closures_, functions that can access variables in
1731-
the enclosing scope.
1729+
A _closure_ does support accessing the enclosing scope; below we will create
1730+
2 _closures_ (nameless functions). Compare how `||` replaces `()` and how
1731+
they try to access `x`:
17321732
1733-
~~~~
1734-
fn call_closure_with_ten(b: |int|) { b(10); }
1733+
~~~~ {.ignore}
1734+
let x = 3;
17351735
1736-
let captured_var = 20;
1737-
let closure = |arg| println!("captured_var={}, arg={}", captured_var, arg);
1736+
// `fun` is an invalid definition
1737+
fn fun () -> () { println!("{}", x) } // cannot capture from enclosing scope
1738+
let closure = || -> () { println!("{}", x) }; // can capture from enclosing scope
17381739
1739-
call_closure_with_ten(closure);
1740+
// `fun_arg` is an invalid definition
1741+
fn fun_arg (arg: int) -> () { println!("{}", arg + x) } // cannot capture
1742+
let closure_arg = |arg: int| -> () { println!("{}", arg + x) }; // can capture
1743+
// ^
1744+
// Requires a type because the implementation needs to know which `+` to use.
1745+
// In the future, the implementation may not need the help.
1746+
1747+
fun(); // Still won't work
1748+
closure(); // Prints: 3
1749+
1750+
fun_arg(7); // Still won't work
1751+
closure_arg(7); // Prints: 10
17401752
~~~~
17411753
17421754
Closures begin with the argument list between vertical bars and are followed by
17431755
a single expression. Remember that a block, `{ <expr1>; <expr2>; ... }`, is
17441756
considered a single expression: it evaluates to the result of the last
17451757
expression it contains if that expression is not followed by a semicolon,
1746-
otherwise the block evaluates to `()`.
1758+
otherwise the block evaluates to `()`, the unit value.
1759+
1760+
In general, return types and all argument types must be specified
1761+
explicitly for function definitions. (As previously mentioned in the
1762+
[Functions section](#functions), omitting the return type from a
1763+
function declaration is synonymous with an explicit declaration of
1764+
return type unit, `()`.)
1765+
1766+
~~~~ {.ignore}
1767+
fn fun (x: int) { println!("{}", x) } // this is same as saying `-> ()`
1768+
fn square(x: int) -> uint { (x * x) as uint } // other return types are explicit
1769+
1770+
// Error: mismatched types: expected `()` but found `uint`
1771+
fn badfun(x: int) { (x * x) as uint }
1772+
~~~~
1773+
1774+
On the other hand, the compiler can usually infer both the argument
1775+
and return types for a closure expression; therefore they are often
1776+
omitted, since both a human reader and the compiler can deduce the
1777+
types from the immediate context. This is in contrast to function
1778+
declarations, which require types to be specified and are not subject
1779+
to type inference. Compare:
17471780
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.
1781+
~~~~ {.ignore}
1782+
// `fun` as a function declaration cannot infer the type of `x`, so it must be provided
1783+
fn fun (x: int) { println!("{}", x) }
1784+
let closure = |x | { println!("{}", x) }; // infers `x: int`, return type `()`
1785+
1786+
// For closures, omitting a return type is *not* synonymous with `-> ()`
1787+
let add_3 = |y | { 3i + y }; // infers `y: int`, return type `int`.
1788+
1789+
fun(10); // Prints 10
1790+
closure(20); // Prints 20
1791+
closure(add_3(30)); // Prints 33
17521792
1793+
fun("String"); // Error: mismatched types
1794+
1795+
// Error: mismatched types
1796+
// inference already assigned `closure` the type `|int| -> ()`
1797+
closure("String");
17531798
~~~~
1754-
let square = |x: int| -> uint { (x * x) as uint };
1799+
1800+
In cases where the compiler needs assistance, the arguments and return
1801+
types may be annotated on closures, using the same notation as shown
1802+
earlier. In the example below, since different types provide an
1803+
implementation for the operator `*`, the argument type for the `x`
1804+
parameter must be explicitly provided.
1805+
1806+
~~~~{.ignore}
1807+
// Error: the type of `x` must be known to be used with `x * x`
1808+
let square = |x | -> uint { (x * x) as uint };
1809+
~~~~
1810+
1811+
In the corrected version, the argument type is explicitly annotated,
1812+
while the return type can still be inferred.
1813+
1814+
~~~~
1815+
let square_explicit = |x: int| -> uint { (x * x) as uint };
1816+
let square_infer = |x: int| { (x * x) as uint };
1817+
1818+
println!("{}", square_explicit(20)); // 400
1819+
println!("{}", square_infer(-20)); // 400
17551820
~~~~
17561821
17571822
There are several forms of closure, each with its own role. The most
@@ -2965,7 +3030,7 @@ use farm::*;
29653030
~~~
29663031

29673032
> *Note:* This feature of the compiler is currently gated behind the
2968-
> `#[feature(globs)]` directive. More about these directives can be found in
3033+
> `#![feature(globs)]` directive. More about these directives can be found in
29693034
> the manual.
29703035
29713036
However, that's not all. You can also rename an item while you're bringing it into scope:
@@ -2980,7 +3045,7 @@ fn main() {
29803045
}
29813046
~~~
29823047

2983-
In general, `use` creates an local alias:
3048+
In general, `use` creates a local alias:
29843049
An alternate path and a possibly different name to access the same item,
29853050
without touching the original, and with both being interchangeable.
29863051

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ 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-
(require 'rust-mode)
15+
(autoload 'rust-mode "rust-mode" nil t)
16+
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
1617
```
1718

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

2122
### `package.el` installation via Marmalade or MELPA
2223

branches/try2/src/etc/emacs/rust-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
;; Font-locking definitions and helpers
170170
(defconst rust-mode-keywords
171171
'("as"
172-
"break"
172+
"box" "break"
173173
"continue" "crate"
174174
"do"
175175
"else" "enum" "extern"

branches/try2/src/etc/zsh/_rust

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ _rustc_opts_lint=(
6868
'unsafe-block[usage of an `unsafe` block]'
6969
'unstable[detects use of #\[unstable\] items (incl. items with no stability attribute)]'
7070
'unused-imports[imports that are never used]'
71-
'unused-must-use[unused result of an type flagged as #\[must_use\]]'
71+
'unused-must-use[unused result of a type flagged as #\[must_use\]]'
7272
"unused-mut[detect mut variables which don't need to be mutable]"
7373
'unused-result[unused result of an expression in a statement]'
7474
'unused-unsafe[unnecessary use of an `unsafe` block]'

0 commit comments

Comments
 (0)