Skip to content

Commit 0932638

Browse files
committed
---
yaml --- r: 189407 b: refs/heads/master c: a600899 h: refs/heads/master i: 189405: c0ce6cf 189403: e987367 189399: 563c5e9 189391: 802bb53 189375: 7df3910 v: v3
1 parent ae8e0e4 commit 0932638

File tree

112 files changed

+769
-1609
lines changed

Some content is hidden

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

112 files changed

+769
-1609
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: 12b846ab80ca054d2fbfb0320d33badbd5ef0112
2+
refs/heads/master: a60089903a54682a96646f13ee6e8b8a406621be
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 270a677d4d698916f5ad103f0afc3c070b8dbeb4
55
refs/heads/try: 649d35e4d830b27806705dc5352c86ab6d6fd1a1

trunk/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The Rust community congregates in a few places:
115115

116116
## Contributing
117117

118-
To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md).
118+
To contribute to Rust, please see [CONTRIBUTING.md](CONTRIBUTING.md).
119119

120120
Rust has an [IRC] culture and most real-time collaboration happens in a
121121
variety of channels on Mozilla's IRC network, irc.mozilla.org. The
@@ -131,4 +131,4 @@ Rust is primarily distributed under the terms of both the MIT license
131131
and the Apache License (Version 2.0), with portions covered by various
132132
BSD-like licenses.
133133
134-
See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and [COPYRIGHT](COPYRIGHT) for details.
134+
See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.

trunk/src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ pub fn make_test<F>(config: &Config, testfile: &Path, f: F) -> test::TestDescAnd
332332
desc: test::TestDesc {
333333
name: make_test_name(config, testfile),
334334
ignore: header::is_test_ignored(config, testfile),
335-
should_panic: test::ShouldPanic::No,
335+
should_fail: test::ShouldFail::No,
336336
},
337337
testfn: f(),
338338
}

trunk/src/doc/complement-design-faq.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,10 @@ bindings.
174174
See also [a long thread][alt] on renaming `let mut` to `var`.
175175

176176
[alt]: https://mail.mozilla.org/pipermail/rust-dev/2014-January/008319.html
177+
178+
## Why no `--x` or `x++`?
179+
180+
Preincrement and postincrement, while convenient, are also fairly complex. They
181+
require knowledge of evaluation order, and often lead to subtle bugs and
182+
undefined behavior in C and C++. `x = x + 1` or `x += 1` is only slightly
183+
longer, but unambiguous.

trunk/src/doc/grammar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ field_expr : expr '.' ident ;
514514
### Array expressions
515515

516516
```antlr
517-
array_expr : '[' "mut" ? array_elems? ']' ;
517+
array_expr : '[' "mut" ? vec_elems? ']' ;
518518
519519
array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
520520
```

trunk/src/doc/intro.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,11 @@ safe concurrent programs.
389389
Here's an example of a concurrent Rust program:
390390
391391
```{rust}
392-
use std::thread;
392+
use std::thread::Thread;
393393
394394
fn main() {
395395
let guards: Vec<_> = (0..10).map(|_| {
396-
thread::scoped(|| {
396+
Thread::scoped(|| {
397397
println!("Hello, world!");
398398
})
399399
}).collect();
@@ -421,16 +421,16 @@ problem.
421421
Let's see an example. This Rust code will not compile:
422422
423423
```{rust,ignore}
424-
use std::thread;
424+
use std::thread::Thread;
425425
426426
fn main() {
427427
let mut numbers = vec![1, 2, 3];
428428
429429
let guards: Vec<_> = (0..3).map(|i| {
430-
thread::scoped(move || {
430+
Thread::scoped(move || {
431431
numbers[i] += 1;
432432
println!("numbers[{}] is {}", i, numbers[i]);
433-
})
433+
});
434434
}).collect();
435435
}
436436
```
@@ -439,10 +439,10 @@ It gives us this error:
439439
440440
```text
441441
7:25: 10:6 error: cannot move out of captured outer variable in an `FnMut` closure
442-
7 thread::scoped(move || {
442+
7 Thread::scoped(move || {
443443
8 numbers[i] += 1;
444444
9 println!("numbers[{}] is {}", i, numbers[i]);
445-
10 })
445+
10 });
446446
error: aborting due to previous error
447447
```
448448
@@ -471,19 +471,19 @@ mutation doesn't cause a data race.
471471
Here's what using an Arc with a Mutex looks like:
472472
473473
```{rust}
474-
use std::thread;
474+
use std::thread::Thread;
475475
use std::sync::{Arc,Mutex};
476476
477477
fn main() {
478478
let numbers = Arc::new(Mutex::new(vec![1, 2, 3]));
479479
480480
let guards: Vec<_> = (0..3).map(|i| {
481481
let number = numbers.clone();
482-
thread::scoped(move || {
482+
Thread::scoped(move || {
483483
let mut array = number.lock().unwrap();
484484
array[i] += 1;
485485
println!("numbers[{}] is {}", i, array[i]);
486-
})
486+
});
487487
}).collect();
488488
}
489489
```
@@ -535,15 +535,15 @@ As an example, Rust's ownership system is _entirely_ at compile time. The
535535
safety check that makes this an error about moved values:
536536
537537
```{rust,ignore}
538-
use std::thread;
538+
use std::thread::Thread;
539539
540540
fn main() {
541541
let numbers = vec![1, 2, 3];
542542
543543
let guards: Vec<_> = (0..3).map(|i| {
544-
thread::scoped(move || {
544+
Thread::scoped(move || {
545545
println!("{}", numbers[i]);
546-
})
546+
});
547547
}).collect();
548548
}
549549
```

trunk/src/doc/reference.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2847,7 +2847,7 @@ automatically dereferenced to make the field access possible.
28472847
### Array expressions
28482848

28492849
```{.ebnf .gram}
2850-
array_expr : '[' "mut" ? array_elems? ']' ;
2850+
array_expr : '[' "mut" ? vec_elems? ']' ;
28512851
28522852
array_elems : [expr [',' expr]*] | [expr ';' expr] ;
28532853
```
@@ -3007,6 +3007,10 @@ A type cast expression is denoted with the binary operator `as`.
30073007
Executing an `as` expression casts the value on the left-hand side to the type
30083008
on the right-hand side.
30093009

3010+
A numeric value can be cast to any numeric type. A raw pointer value can be
3011+
cast to or from any integral type or raw pointer type. Any other cast is
3012+
unsupported and will fail to compile.
3013+
30103014
An example of an `as` expression:
30113015

30123016
```

trunk/src/doc/style/errors/ergonomics.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ fn write_info(info: &Info) -> Result<(), IoError> {
2222
let mut file = File::open_mode(&Path::new("my_best_friends.txt"),
2323
Open, Write);
2424
// Early return on error
25-
try!(file.write_line(&format!("name: {}", info.name)));
26-
try!(file.write_line(&format!("age: {}", info.age)));
27-
try!(file.write_line(&format!("rating: {}", info.rating)));
25+
try!(file.write_line(format!("name: {}", info.name).as_slice()));
26+
try!(file.write_line(format!("age: {}", info.age).as_slice()));
27+
try!(file.write_line(format!("rating: {}", info.rating).as_slice()));
2828
return Ok(());
2929
}
3030
```
@@ -44,15 +44,15 @@ fn write_info(info: &Info) -> Result<(), IoError> {
4444
let mut file = File::open_mode(&Path::new("my_best_friends.txt"),
4545
Open, Write);
4646
// Early return on error
47-
match file.write_line(&format!("name: {}", info.name)) {
47+
match file.write_line(format!("name: {}", info.name).as_slice()) {
4848
Ok(_) => (),
4949
Err(e) => return Err(e)
5050
}
51-
match file.write_line(&format!("age: {}", info.age)) {
51+
match file.write_line(format!("age: {}", info.age).as_slice()) {
5252
Ok(_) => (),
5353
Err(e) => return Err(e)
5454
}
55-
return file.write_line(&format!("rating: {}", info.rating));
55+
return file.write_line(format!("rating: {}", info.rating).as_slice());
5656
}
5757
```
5858

trunk/src/doc/trpl/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
* [Standard Input](standard-input.md)
1717
* [Guessing Game](guessing-game.md)
1818
* [II: Intermediate Rust](intermediate.md)
19+
* [More Strings](more-strings.md)
1920
* [Crates and Modules](crates-and-modules.md)
2021
* [Testing](testing.md)
2122
* [Pointers](pointers.md)
2223
* [Ownership](ownership.md)
23-
* [More Strings](more-strings.md)
2424
* [Patterns](patterns.md)
2525
* [Method Syntax](method-syntax.md)
2626
* [Closures](closures.md)

trunk/src/doc/trpl/concurrency.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,15 @@ method which has this signature:
223223
fn lock(&self) -> LockResult<MutexGuard<T>>
224224
```
225225

226-
Because `Send` is not implemented for `MutexGuard<T>`, we can't transfer the
227-
guard across thread boundaries, which gives us our error.
226+
If we [look at the code for MutexGuard](https://github.com/rust-lang/rust/blob/ca4b9674c26c1de07a2042cb68e6a062d7184cef/src/libstd/sync/mutex.rs#L172), we'll see
227+
this:
228+
229+
```ignore
230+
__marker: marker::NoSend,
231+
```
232+
233+
Because our guard is `NoSend`, it's not `Send`. Which means we can't actually
234+
transfer the guard across thread boundaries, which gives us our error.
228235

229236
We can use `Arc<T>` to fix this. Here's the working version:
230237

trunk/src/doc/trpl/method-syntax.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,7 @@ You can think of this first parameter as being the `x` in `x.foo()`. The three
5050
variants correspond to the three kinds of thing `x` could be: `self` if it's
5151
just a value on the stack, `&self` if it's a reference, and `&mut self` if it's
5252
a mutable reference. We should default to using `&self`, as it's the most
53-
common. Here's an example of all three variants:
54-
55-
```rust
56-
struct Circle {
57-
x: f64,
58-
y: f64,
59-
radius: f64,
60-
}
61-
62-
impl Circle {
63-
fn reference(&self) {
64-
println!("taking self by reference!");
65-
}
66-
67-
fn mutable_reference(&mut self) {
68-
println!("taking self by mutable reference!");
69-
}
70-
71-
fn takes_ownership(self) {
72-
println!("taking ownership of self!");
73-
}
74-
}
75-
```
53+
common.
7654

7755
Finally, as you may remember, the value of the area of a circle is `π*r²`.
7856
Because we took the `&self` parameter to `area`, we can use it just like any

trunk/src/doc/trpl/more-strings.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,7 @@ This will print:
278278

279279
Many more bytes than graphemes!
280280

281-
# `Deref` coercions
281+
# Other Documentation
282282

283-
References to `String`s will automatically coerce into `&str`s. Like this:
284-
285-
```
286-
fn hello(s: &str) {
287-
println!("Hello, {}!", s);
288-
}
289-
290-
let slice = "Steve";
291-
let string = "Steve".to_string();
292-
293-
hello(slice);
294-
hello(&string);
295-
```
283+
* [the `&str` API documentation](../std/str/index.html)
284+
* [the `String` API documentation](../std/string/index.html)

trunk/src/doc/trpl/plugins.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ that implements Roman numeral integer literals.
6363

6464
```ignore
6565
#![crate_type="dylib"]
66-
#![feature(plugin_registrar, rustc_private)]
66+
#![feature(plugin_registrar)]
6767
6868
extern crate syntax;
6969
extern crate rustc;
@@ -92,13 +92,13 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
9292
}
9393
};
9494
95-
let mut text = &*text;
95+
let mut text = &text;
9696
let mut total = 0;
9797
while !text.is_empty() {
9898
match NUMERALS.iter().find(|&&(rn, _)| text.starts_with(rn)) {
9999
Some(&(rn, val)) => {
100100
total += val;
101-
text = &text[rn.len()..];
101+
text = text.slice_from(rn.len());
102102
}
103103
None => {
104104
cx.span_err(sp, "invalid Roman numeral");
@@ -107,7 +107,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
107107
}
108108
}
109109
110-
MacEager::expr(cx.expr_u32(sp, total))
110+
MacEager::expr(cx.expr_usize(sp, total))
111111
}
112112
113113
#[plugin_registrar]

trunk/src/doc/trpl/pointers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@ use-case for boxes.
634634
### Returning data
635635

636636
This is important enough to have its own section entirely. The TL;DR is this:
637-
you don't want to return pointers, even when you might in a language like C or
638-
C++.
637+
you don't generally want to return pointers, even when you might in a language
638+
like C or C++.
639639

640640
See [Returning Pointers](#returning-pointers) below for more.
641641

trunk/src/doc/trpl/traits.md

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -435,46 +435,3 @@ println!("the inverse of {} is {:?}", 2.0f64, inverse(2.0f64));
435435
println!("the inverse of {} is {:?}", 0.0f32, inverse(0.0f32));
436436
println!("the inverse of {} is {:?}", 0.0f64, inverse(0.0f64));
437437
```
438-
439-
## Default methods
440-
441-
There's one last feature of traits we should cover: default methods. It's
442-
easiest just to show an example:
443-
444-
```rust
445-
trait Foo {
446-
fn bar(&self);
447-
448-
fn baz(&self) { println!("We called baz."); }
449-
}
450-
```
451-
452-
Implementors of the `Foo` trait need to implement `bar()`, but they don't
453-
need to implement `baz()`. They'll get this default behavior. They can
454-
override the default if they so choose:
455-
456-
```rust
457-
# trait Foo {
458-
# fn bar(&self);
459-
# fn baz(&self) { println!("We called baz."); }
460-
# }
461-
struct UseDefault;
462-
463-
impl Foo for UseDefault {
464-
fn bar(&self) { println!("We called bar."); }
465-
}
466-
467-
struct OverrideDefault;
468-
469-
impl Foo for OverrideDefault {
470-
fn bar(&self) { println!("We called bar."); }
471-
472-
fn baz(&self) { println!("Override baz!"); }
473-
}
474-
475-
let default = UseDefault;
476-
default.baz(); // prints "We called bar."
477-
478-
let over = OverrideDefault;
479-
over.baz(); // prints "Override baz!"
480-
```

trunk/src/libarena/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn test_arena_destructors() {
323323
}
324324

325325
#[test]
326-
#[should_panic]
326+
#[should_fail]
327327
fn test_arena_destructors_fail() {
328328
let arena = Arena::new();
329329
// Put some stuff in the arena.

trunk/src/libcollections/enum_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ mod test {
490490
}
491491

492492
#[test]
493-
#[should_panic]
493+
#[should_fail]
494494
fn test_overflow() {
495495
#[allow(dead_code)]
496496
#[derive(Copy)]

trunk/src/libcollections/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
//! // for details, and the function `pad` can be used to pad strings.
199199
//! let decimals = f.precision().unwrap_or(3);
200200
//! let string = f64::to_str_exact(magnitude, decimals);
201-
//! f.pad_integral(true, "", &string)
201+
//! f.pad_integral(true, "", string.as_slice())
202202
//! }
203203
//! }
204204
//!

0 commit comments

Comments
 (0)