Skip to content

Commit ddddf8a

Browse files
committed
---
yaml --- r: 187567 b: refs/heads/tmp c: f73457a h: refs/heads/master i: 187565: 6023bf0 187563: 7e97eea 187559: f302449 187551: 08b370d v: v3
1 parent 2da35f0 commit ddddf8a

Some content is hidden

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

62 files changed

+1752
-847
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 9f2b0671f88b2cc6bb73575db47d265dbb246e34
37+
refs/heads/tmp: f73457a1cc18ac623b17d9c3cb8d55b6bcbef70e
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ To contribute to Rust, please see [CONTRIBUTING.md](CONTRIBUTING.md).
111111
Rust has an [IRC] culture and most real-time collaboration happens in a
112112
variety of channels on Mozilla's IRC network, irc.mozilla.org. The
113113
most popular channel is [#rust], a venue for general discussion about
114-
Rust, and a good place to ask for help,
114+
Rust, and a good place to ask for help.
115115

116116
[IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat
117117
[#rust]: irc://irc.mozilla.org/rust

branches/tmp/src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
268268
logfile: config.logfile.clone(),
269269
run_tests: true,
270270
run_benchmarks: true,
271-
nocapture: false,
271+
nocapture: env::var("RUST_TEST_NOCAPTURE").is_ok(),
272272
color: test::AutoColor,
273273
}
274274
}

branches/tmp/src/compiletest/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
5858
fn parse_expected(last_nonfollow_error: Option<uint>,
5959
line_num: uint,
6060
line: &str) -> Option<(WhichLine, ExpectedError)> {
61-
let start = match line.find_str("//~") { Some(i) => i, None => return None };
61+
let start = match line.find("//~") { Some(i) => i, None => return None };
6262
let (follow, adjusts) = if line.char_at(start + 3) == '|' {
6363
(true, 0)
6464
} else {

branches/tmp/src/compiletest/header.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::env;
12+
1113
use common::Config;
1214
use common;
1315
use util;
@@ -125,6 +127,16 @@ pub fn load_props(testfile: &Path) -> TestProps {
125127
true
126128
});
127129

130+
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_TASKS"] {
131+
match env::var(key) {
132+
Ok(val) =>
133+
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {
134+
exec_env.push((key.to_string(), val))
135+
},
136+
Err(..) => {}
137+
}
138+
}
139+
128140
TestProps {
129141
error_patterns: error_patterns,
130142
compile_flags: compile_flags,
@@ -330,7 +342,7 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
330342
pub fn parse_name_value_directive(line: &str, directive: &str)
331343
-> Option<String> {
332344
let keycolon = format!("{}:", directive);
333-
match line.find_str(&keycolon) {
345+
match line.find(&keycolon) {
334346
Some(colon) => {
335347
let value = line[(colon + keycolon.len()) .. line.len()].to_string();
336348
debug!("{}: {}", directive, value);

branches/tmp/src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
847847
check_lines.iter().map(|s| {
848848
s
849849
.trim()
850-
.split_str("[...]")
850+
.split("[...]")
851851
.map(|x| x.to_string())
852852
.collect()
853853
}).collect();
@@ -866,7 +866,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
866866
None
867867
}
868868
} else {
869-
rest.find_str(frag)
869+
rest.find(frag)
870870
};
871871
match found {
872872
None => {

branches/tmp/src/doc/intro.md

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -426,39 +426,33 @@ use std::thread::Thread;
426426
fn main() {
427427
let mut numbers = vec![1, 2, 3];
428428
429-
for i in 0..3 {
430-
Thread::spawn(move || {
429+
let guards: Vec<_> = (0..3).map(|i| {
430+
Thread::scoped(move || {
431431
for j in 0..3 { numbers[j] += 1 }
432432
});
433-
}
433+
}).collect();
434434
}
435435
```
436436
437437
It gives us this error:
438438
439439
```text
440-
6:71 error: capture of moved value: `numbers`
441-
for j in 0..3 { numbers[j] += 1 }
442-
^~~~~~~
443-
7:50 note: `numbers` moved into closure environment here
444-
spawn(move || {
445-
for j in 0..3 { numbers[j] += 1 }
446-
});
447-
6:79 error: cannot assign to immutable dereference (dereference is implicit, due to indexing)
448-
for j in 0..3 { numbers[j] += 1 }
449-
^~~~~~~~~~~~~~~
440+
7:29: 9:10 error: cannot move out of captured outer variable in an `FnMut` closure
441+
7 Thread::scoped(move || {
442+
8 for j in 0..3 { numbers[j] += 1 }
443+
9 });
450444
```
451445
452-
It mentions that "numbers moved into closure environment". Because we
453-
declared the closure as a moving closure, and it referred to
454-
`numbers`, the closure will try to take ownership of the vector. But
455-
the closure itself is created in a loop, and hence we will actually
456-
create three closures, one for every iteration of the loop. This means
457-
that all three of those closures would try to own `numbers`, which is
458-
impossible -- `numbers` must have just one owner. Rust detects this
459-
and gives us the error: we claim that `numbers` has ownership, but our
460-
code tries to make three owners. This may cause a safety problem, so
461-
Rust disallows it.
446+
It mentions that "captured outer variable in an `FnMut` closure".
447+
Because we declared the closure as a moving closure, and it referred
448+
to `numbers`, the closure will try to take ownership of the
449+
vector. But the closure itself is created in a loop, and hence we will
450+
actually create three closures, one for every iteration of the
451+
loop. This means that all three of those closures would try to own
452+
`numbers`, which is impossible -- `numbers` must have just one
453+
owner. Rust detects this and gives us the error: we claim that
454+
`numbers` has ownership, but our code tries to make three owners. This
455+
may cause a safety problem, so Rust disallows it.
462456
463457
What to do here? Rust has two types that helps us: `Arc<T>` and `Mutex<T>`.
464458
*Arc* stands for "atomically reference counted". In other words, an Arc will
@@ -480,14 +474,14 @@ use std::sync::{Arc,Mutex};
480474
fn main() {
481475
let numbers = Arc::new(Mutex::new(vec![1, 2, 3]));
482476
483-
for i in 0..3 {
477+
let guards: Vec<_> = (0..3).map(|i| {
484478
let number = numbers.clone();
485-
Thread::spawn(move || {
479+
Thread::scoped(move || {
486480
let mut array = number.lock().unwrap();
487481
array[i] += 1;
488482
println!("numbers[{}] is {}", i, array[i]);
489483
});
490-
}
484+
}).collect();
491485
}
492486
```
493487
@@ -516,8 +510,10 @@ numbers[1] is 3
516510
numbers[0] is 2
517511
```
518512
519-
Each time, we get a slightly different output, because each thread works in a
520-
different order. You may not get the same output as this sample, even.
513+
Each time, we can get a slithtly different output because the threads
514+
are not quaranteed to run in any set order. If you get the same order
515+
every time it is because each of these threads are very small and
516+
complete too fast for their indeterminate behavior to surface.
521517
522518
The important part here is that the Rust compiler was able to use ownership to
523519
give us assurance _at compile time_ that we weren't doing something incorrect
@@ -539,13 +535,13 @@ safety check that makes this an error about moved values:
539535
use std::thread::Thread;
540536
541537
fn main() {
542-
let vec = vec![1, 2, 3];
543-
544-
for i in 0..3 {
545-
Thread::spawn(move || {
546-
println!("{}", vec[i]);
538+
let numbers = vec![1, 2, 3];
539+
540+
let guards: Vec<_> = (0..3).map(|i| {
541+
Thread::scoped(move || {
542+
println!("{}", numbers[i]);
547543
});
548-
}
544+
}).collect();
549545
}
550546
```
551547

branches/tmp/src/doc/reference.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ This last example is different because it is not possible to use the suffix
515515
syntax with a floating point literal ending in a period. `2.f64` would attempt
516516
to call a method named `f64` on `2`.
517517

518+
The representation semantics of floating-point numbers are described in
519+
["Machine Types"](#machine-types).
520+
518521
#### Boolean literals
519522

520523
The two values of the boolean type are written `true` and `false`.

branches/tmp/src/doc/trpl/crates-and-modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Rust has two distinct terms that relate to the module system: *crate* and
1212
*module*. A crate is synonymous with a *library* or *package* in other
1313
languages. Hence "Cargo" as the name of Rust's package management tool: you
1414
ship your crates to others with Cargo. Crates can produce an executable or a
15-
shared library, depending on the project.
15+
library, depending on the project.
1616

1717
Each crate has an implicit *root module* that contains the code for that crate.
1818
You can then define a tree of sub-modules under that root module. Modules allow

branches/tmp/src/doc/trpl/more-strings.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ string literal or a `String`.
3838

3939
# String
4040

41-
A `String` is a heap-allocated string. This string is growable, and is also
42-
guaranteed to be UTF-8.
41+
A `String` is a heap-allocated string. This string is growable, and is
42+
also guaranteed to be UTF-8. `String`s are commonly created by
43+
converting from a string slice using the `to_string` method.
4344

4445
```
4546
let mut s = "Hello".to_string();
@@ -49,7 +50,7 @@ s.push_str(", world.");
4950
println!("{}", s);
5051
```
5152

52-
You can coerce a `String` into a `&str` by dereferencing it:
53+
A reference to a `String` will automatically coerce to a string slice:
5354

5455
```
5556
fn takes_slice(slice: &str) {
@@ -58,7 +59,7 @@ fn takes_slice(slice: &str) {
5859
5960
fn main() {
6061
let s = "Hello".to_string();
61-
takes_slice(&*s);
62+
takes_slice(&s);
6263
}
6364
```
6465

branches/tmp/src/doc/trpl/static-and-dynamic-dispatch.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ fn main() {
7979
}
8080
```
8181

82-
This has some upsides: static dispatching of any method calls, allowing for
83-
inlining and hence usually higher performance. It also has some downsides:
84-
causing code bloat due to many copies of the same function existing in the
85-
binary, one for each type.
82+
This has a great upside: static dispatch allows function calls to be
83+
inlined because the callee is known at compile time, and inlining is
84+
the key to good optimization. Static dispatch is fast, but it comes at
85+
a tradeoff: 'code bloat', due to many copies of the same function
86+
existing in the binary, one for each type.
8687

8788
Furthermore, compilers aren’t perfect and may “optimize” code to become slower.
8889
For example, functions inlined too eagerly will bloat the instruction cache

branches/tmp/src/doc/trpl/strings.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ compiled program, and exists for the entire duration it runs. The `string`
2525
binding is a reference to this statically allocated string. String slices
2626
have a fixed size, and cannot be mutated.
2727

28-
A `String`, on the other hand, is an in-memory string. This string is
29-
growable, and is also guaranteed to be UTF-8.
28+
A `String`, on the other hand, is a heap-allocated string. This string
29+
is growable, and is also guaranteed to be UTF-8. `String`s are
30+
commonly created by converting from a string slice using the
31+
`to_string` method.
3032

3133
```{rust}
3234
let mut s = "Hello".to_string(); // mut s: String

0 commit comments

Comments
 (0)