Skip to content

Commit ffd6861

Browse files
committed
---
yaml --- r: 192437 b: refs/heads/auto c: 4a81e66 h: refs/heads/master i: 192435: 3acc7f5 v: v3
1 parent 949f53e commit ffd6861

File tree

184 files changed

+1012
-3203
lines changed

Some content is hidden

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

184 files changed

+1012
-3203
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: fcf2ba794ec9522296db1df438e89dc70e447f59
13+
refs/heads/auto: 4a81e66b44f6e7dbbd8741b562ea7f6ac4d799bc
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/compiletest/compiletest.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#![feature(std_misc)]
2121
#![feature(test)]
2222
#![feature(path_ext)]
23-
#![feature(convert)]
24-
#![feature(str_char)]
2523

2624
#![deny(warnings)]
2725

@@ -117,7 +115,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
117115

118116
fn opt_path(m: &getopts::Matches, nm: &str) -> PathBuf {
119117
match m.opt_str(nm) {
120-
Some(s) => PathBuf::from(&s),
118+
Some(s) => PathBuf::new(&s),
121119
None => panic!("no option (=path) found for {}", nm),
122120
}
123121
}
@@ -132,18 +130,18 @@ pub fn parse_config(args: Vec<String> ) -> Config {
132130
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
133131
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
134132
rustc_path: opt_path(matches, "rustc-path"),
135-
clang_path: matches.opt_str("clang-path").map(|s| PathBuf::from(&s)),
133+
clang_path: matches.opt_str("clang-path").map(|s| PathBuf::new(&s)),
136134
valgrind_path: matches.opt_str("valgrind-path"),
137135
force_valgrind: matches.opt_present("force-valgrind"),
138-
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| PathBuf::from(&s)),
136+
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| PathBuf::new(&s)),
139137
src_base: opt_path(matches, "src-base"),
140138
build_base: opt_path(matches, "build-base"),
141139
aux_base: opt_path(matches, "aux-base"),
142140
stage_id: matches.opt_str("stage-id").unwrap(),
143141
mode: matches.opt_str("mode").unwrap().parse().ok().expect("invalid mode"),
144142
run_ignored: matches.opt_present("ignored"),
145143
filter: filter,
146-
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
144+
logfile: matches.opt_str("logfile").map(|s| PathBuf::new(&s)),
147145
runtool: matches.opt_str("runtool"),
148146
host_rustcflags: matches.opt_str("host-rustcflags"),
149147
target_rustcflags: matches.opt_str("target-rustcflags"),

branches/auto/src/compiletest/header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,10 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
328328

329329
fn parse_pp_exact(line: &str, testfile: &Path) -> Option<PathBuf> {
330330
match parse_name_value_directive(line, "pp-exact") {
331-
Some(s) => Some(PathBuf::from(&s)),
331+
Some(s) => Some(PathBuf::new(&s)),
332332
None => {
333333
if parse_name_directive(line, "pp-exact") {
334-
testfile.file_name().map(|s| PathBuf::from(s))
334+
testfile.file_name().map(|s| PathBuf::new(s))
335335
} else {
336336
None
337337
}

branches/auto/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ fn aux_output_dir_name(config: &Config, testfile: &Path) -> PathBuf {
14401440
}
14411441

14421442
fn output_testname(testfile: &Path) -> PathBuf {
1443-
PathBuf::from(testfile.file_stem().unwrap())
1443+
PathBuf::new(testfile.file_stem().unwrap())
14441444
}
14451445

14461446
fn output_base_name(config: &Config, testfile: &Path) -> PathBuf {

branches/auto/src/doc/intro.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,16 @@ It gives us this error:
446446
error: aborting due to previous error
447447
```
448448
449-
This is a little confusing because there are two closures here: the one passed
450-
to `map`, and the one passed to `thread::scoped`. In this case, the closure for
451-
`thread::scoped` is attempting to reference `numbers`, a `Vec<i32>`. This
452-
closure is a `FnOnce` closure, as that’s what `thread::scoped` takes as an
453-
argument. `FnOnce` closures take ownership of their environment. That’s fine,
454-
but there’s one detail: because of `map`, we’re going to make three of these
455-
closures. And since all three try to take ownership of `numbers`, that would be
456-
a problem. That’s what it means by ‘cannot move out of captured outer
457-
variable’: our `thread::scoped` closure wants to take ownership, and it can’t,
458-
because the closure for `map` won’t let it.
449+
It mentions that "captured outer variable in an `FnMut` closure".
450+
Because we declared the closure as a moving closure, and it referred
451+
to `numbers`, the closure will try to take ownership of the
452+
vector. But the closure itself is created in a loop, and hence we will
453+
actually create three closures, one for every iteration of the
454+
loop. This means that all three of those closures would try to own
455+
`numbers`, which is impossible -- `numbers` must have just one
456+
owner. Rust detects this and gives us the error: we claim that
457+
`numbers` has ownership, but our code tries to make three owners. This
458+
may cause a safety problem, so Rust disallows it.
459459
460460
What to do here? Rust has two types that helps us: `Arc<T>` and `Mutex<T>`.
461461
*Arc* stands for "atomically reference counted". In other words, an Arc will

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

Lines changed: 73 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% Crates and Modules
22

3-
When a project starts getting large, it's considered good software
3+
When a project starts getting large, it's considered a good software
44
engineering practice to split it up into a bunch of smaller pieces, and then
55
fit them together. It's also important to have a well-defined interface, so
66
that some of your functionality is private, and some is public. To facilitate
@@ -24,23 +24,23 @@ in different languages. To keep things simple, we'll stick to "greetings" and
2424
two languages for those phrases to be in. We'll use this module layout:
2525

2626
```text
27-
+-----------+
28-
+---| greetings |
29-
| +-----------+
30-
+---------+ |
31-
+---| english |---+
32-
| +---------+ | +-----------+
33-
| +---| farewells |
34-
+---------+ | +-----------+
27+
+-----------+
28+
+---| greetings |
29+
| +-----------+
30+
+---------+ |
31+
| english |---+
32+
+---------+ | +-----------+
33+
| +---| farewells |
34+
+---------+ | +-----------+
3535
| phrases |---+
36-
+---------+ | +-----------+
37-
| +---| greetings |
38-
| +----------+ | +-----------+
39-
+---| japanese |--+
40-
+----------+ |
41-
| +-----------+
42-
+---| farewells |
43-
+-----------+
36+
+---------+ | +-----------+
37+
| +---| greetings |
38+
+----------+ | +-----------+
39+
| japanese |---+
40+
+----------+ |
41+
| +-----------+
42+
+---| farewells |
43+
+-----------+
4444
```
4545

4646
In this example, `phrases` is the name of our crate. All of the rest are
@@ -76,19 +76,25 @@ To define each of our modules, we use the `mod` keyword. Let's make our
7676
`src/lib.rs` look like this:
7777

7878
```
79+
// in src/lib.rs
80+
7981
mod english {
8082
mod greetings {
83+
8184
}
8285
8386
mod farewells {
87+
8488
}
8589
}
8690
8791
mod japanese {
8892
mod greetings {
93+
8994
}
9095
9196
mod farewells {
97+
9298
}
9399
}
94100
```
@@ -139,7 +145,11 @@ mod english;
139145
```
140146

141147
If we do that, Rust will expect to find either a `english.rs` file, or a
142-
`english/mod.rs` file with the contents of our module.
148+
`english/mod.rs` file with the contents of our module:
149+
150+
```{rust,ignore}
151+
// contents of our module go here
152+
```
143153

144154
Note that in these files, you don't need to re-declare the module: that's
145155
already been done with the initial `mod` declaration.
@@ -171,7 +181,10 @@ $ tree .
171181
`src/lib.rs` is our crate root, and looks like this:
172182

173183
```{rust,ignore}
184+
// in src/lib.rs
185+
174186
mod english;
187+
175188
mod japanese;
176189
```
177190

@@ -182,7 +195,10 @@ chosen the second. Both `src/english/mod.rs` and `src/japanese/mod.rs` look
182195
like this:
183196

184197
```{rust,ignore}
198+
// both src/english/mod.rs and src/japanese/mod.rs
199+
185200
mod greetings;
201+
186202
mod farewells;
187203
```
188204

@@ -198,6 +214,8 @@ both empty at the moment. Let's add some functions.
198214
Put this in `src/english/greetings.rs`:
199215

200216
```rust
217+
// in src/english/greetings.rs
218+
201219
fn hello() -> String {
202220
"Hello!".to_string()
203221
}
@@ -206,6 +224,8 @@ fn hello() -> String {
206224
Put this in `src/english/farewells.rs`:
207225

208226
```rust
227+
// in src/english/farewells.rs
228+
209229
fn goodbye() -> String {
210230
"Goodbye.".to_string()
211231
}
@@ -228,6 +248,8 @@ about the module system.
228248
Put this in `src/japanese/farewells.rs`:
229249

230250
```rust
251+
// in src/japanese/farewells.rs
252+
231253
fn goodbye() -> String {
232254
"さようなら".to_string()
233255
}
@@ -243,9 +265,11 @@ another crate.
243265
We have a library crate. Let's make an executable crate that imports and uses
244266
our library.
245267

246-
Make a `src/main.rs` and put this in it (it won't quite compile yet):
268+
Make a `src/main.rs` and put this in it: (it won't quite compile yet)
247269

248270
```rust,ignore
271+
// in src/main.rs
272+
249273
extern crate phrases;
250274
251275
fn main() {
@@ -296,6 +320,8 @@ keyword. Let's focus on the `english` module first, so let's reduce our `src/mai
296320
to just this:
297321
298322
```{rust,ignore}
323+
// in src/main.rs
324+
299325
extern crate phrases;
300326
301327
fn main() {
@@ -307,20 +333,28 @@ fn main() {
307333
In our `src/lib.rs`, let's add `pub` to the `english` module declaration:
308334
309335
```{rust,ignore}
336+
// in src/lib.rs
337+
310338
pub mod english;
339+
311340
mod japanese;
312341
```
313342
314343
And in our `src/english/mod.rs`, let's make both `pub`:
315344
316345
```{rust,ignore}
346+
// in src/english/mod.rs
347+
317348
pub mod greetings;
349+
318350
pub mod farewells;
319351
```
320352
321353
In our `src/english/greetings.rs`, let's add `pub` to our `fn` declaration:
322354
323355
```{rust,ignore}
356+
// in src/english/greetings.rs
357+
324358
pub fn hello() -> String {
325359
"Hello!".to_string()
326360
}
@@ -329,6 +363,8 @@ pub fn hello() -> String {
329363
And also in `src/english/farewells.rs`:
330364
331365
```{rust,ignore}
366+
// in src/english/farewells.rs
367+
332368
pub fn goodbye() -> String {
333369
"Goodbye.".to_string()
334370
}
@@ -364,6 +400,8 @@ Rust has a `use` keyword, which allows us to import names into our local scope.
364400
Let's change our `src/main.rs` to look like this:
365401
366402
```{rust,ignore}
403+
// in src/main.rs
404+
367405
extern crate phrases;
368406

369407
use phrases::english::greetings;
@@ -422,19 +460,21 @@ Could not compile `phrases`.
422460
```
423461
424462
If we're importing multiple names from the same module, we don't have to type it out
425-
twice. Instead of this:
463+
twice. Rust has a shortcut syntax for writing this:
426464
427465
```{rust,ignore}
428466
use phrases::english::greetings;
429467
use phrases::english::farewells;
430468
```
431469
432-
We can use this shortcut:
470+
You use curly braces:
433471
434472
```{rust,ignore}
435473
use phrases::english::{greetings, farewells};
436474
```
437475
476+
These two declarations are equivalent, but the second is a lot less typing.
477+
438478
## Re-exporting with `pub use`
439479
440480
You don't just use `use` to shorten identifiers. You can also use it inside of your crate
@@ -444,6 +484,8 @@ interface that may not directly map to your internal code organization.
444484
Let's look at an example. Modify your `src/main.rs` to read like this:
445485
446486
```{rust,ignore}
487+
// in src/main.rs
488+
447489
extern crate phrases;
448490
449491
use phrases::english::{greetings,farewells};
@@ -461,13 +503,18 @@ fn main() {
461503
Then, modify your `src/lib.rs` to make the `japanese` mod public:
462504
463505
```{rust,ignore}
506+
// in src/lib.rs
507+
464508
pub mod english;
509+
465510
pub mod japanese;
466511
```
467512
468513
Next, make the two functions public, first in `src/japanese/greetings.rs`:
469514
470515
```{rust,ignore}
516+
// in src/japanese/greetings.rs
517+
471518
pub fn hello() -> String {
472519
"こんにちは".to_string()
473520
}
@@ -476,6 +523,8 @@ pub fn hello() -> String {
476523
And then in `src/japanese/farewells.rs`:
477524
478525
```{rust,ignore}
526+
// in src/japanese/farewells.rs
527+
479528
pub fn goodbye() -> String {
480529
"さようなら".to_string()
481530
}
@@ -484,10 +533,13 @@ pub fn goodbye() -> String {
484533
Finally, modify your `src/japanese/mod.rs` to read like this:
485534
486535
```{rust,ignore}
536+
// in src/japanese/mod.rs
537+
487538
pub use self::greetings::hello;
488539
pub use self::farewells::goodbye;
489540
490541
mod greetings;
542+
491543
mod farewells;
492544
```
493545

0 commit comments

Comments
 (0)