Skip to content

Commit 938724e

Browse files
committed
---
yaml --- r: 192238 b: refs/heads/master c: 7101ff4 h: refs/heads/master v: v3
1 parent 3a911db commit 938724e

File tree

176 files changed

+3001
-987
lines changed

Some content is hidden

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

176 files changed

+3001
-987
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: 6a5b1e9f8ef3b46ad46f9878e5869153f081a32b
2+
refs/heads/master: 7101ff4513c1756c69d6023a391fdebe0809ea37
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a923278c6278c63468d74772c58dbf788e88f58c
55
refs/heads/try: ce76bff75603a754d092456285ff455eb871633d

trunk/src/compiletest/compiletest.rs

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

2426
#![deny(warnings)]
2527

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

116118
fn opt_path(m: &getopts::Matches, nm: &str) -> PathBuf {
117119
match m.opt_str(nm) {
118-
Some(s) => PathBuf::new(&s),
120+
Some(s) => PathBuf::from(&s),
119121
None => panic!("no option (=path) found for {}", nm),
120122
}
121123
}
@@ -130,18 +132,18 @@ pub fn parse_config(args: Vec<String> ) -> Config {
130132
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
131133
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
132134
rustc_path: opt_path(matches, "rustc-path"),
133-
clang_path: matches.opt_str("clang-path").map(|s| PathBuf::new(&s)),
135+
clang_path: matches.opt_str("clang-path").map(|s| PathBuf::from(&s)),
134136
valgrind_path: matches.opt_str("valgrind-path"),
135137
force_valgrind: matches.opt_present("force-valgrind"),
136-
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| PathBuf::new(&s)),
138+
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| PathBuf::from(&s)),
137139
src_base: opt_path(matches, "src-base"),
138140
build_base: opt_path(matches, "build-base"),
139141
aux_base: opt_path(matches, "aux-base"),
140142
stage_id: matches.opt_str("stage-id").unwrap(),
141143
mode: matches.opt_str("mode").unwrap().parse().ok().expect("invalid mode"),
142144
run_ignored: matches.opt_present("ignored"),
143145
filter: filter,
144-
logfile: matches.opt_str("logfile").map(|s| PathBuf::new(&s)),
146+
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
145147
runtool: matches.opt_str("runtool"),
146148
host_rustcflags: matches.opt_str("host-rustcflags"),
147149
target_rustcflags: matches.opt_str("target-rustcflags"),

trunk/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::new(&s)),
331+
Some(s) => Some(PathBuf::from(&s)),
332332
None => {
333333
if parse_name_directive(line, "pp-exact") {
334-
testfile.file_name().map(|s| PathBuf::new(s))
334+
testfile.file_name().map(|s| PathBuf::from(s))
335335
} else {
336336
None
337337
}

trunk/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::new(testfile.file_stem().unwrap())
1443+
PathBuf::from(testfile.file_stem().unwrap())
14441444
}
14451445

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

trunk/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-
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.
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.
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

trunk/src/doc/trpl/crates-and-modules.md

Lines changed: 21 additions & 73 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 a good software
3+
When a project starts getting large, it's considered 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,25 +76,19 @@ 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-
8179
mod english {
8280
mod greetings {
83-
8481
}
8582
8683
mod farewells {
87-
8884
}
8985
}
9086
9187
mod japanese {
9288
mod greetings {
93-
9489
}
9590
9691
mod farewells {
97-
9892
}
9993
}
10094
```
@@ -145,11 +139,7 @@ mod english;
145139
```
146140

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

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

183173
```{rust,ignore}
184-
// in src/lib.rs
185-
186174
mod english;
187-
188175
mod japanese;
189176
```
190177

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

197184
```{rust,ignore}
198-
// both src/english/mod.rs and src/japanese/mod.rs
199-
200185
mod greetings;
201-
202186
mod farewells;
203187
```
204188

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

216200
```rust
217-
// in src/english/greetings.rs
218-
219201
fn hello() -> String {
220202
"Hello!".to_string()
221203
}
@@ -224,8 +206,6 @@ fn hello() -> String {
224206
Put this in `src/english/farewells.rs`:
225207

226208
```rust
227-
// in src/english/farewells.rs
228-
229209
fn goodbye() -> String {
230210
"Goodbye.".to_string()
231211
}
@@ -248,8 +228,6 @@ about the module system.
248228
Put this in `src/japanese/farewells.rs`:
249229

250230
```rust
251-
// in src/japanese/farewells.rs
252-
253231
fn goodbye() -> String {
254232
"さようなら".to_string()
255233
}
@@ -265,11 +243,9 @@ another crate.
265243
We have a library crate. Let's make an executable crate that imports and uses
266244
our library.
267245

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

270248
```rust,ignore
271-
// in src/main.rs
272-
273249
extern crate phrases;
274250
275251
fn main() {
@@ -320,8 +296,6 @@ keyword. Let's focus on the `english` module first, so let's reduce our `src/mai
320296
to just this:
321297
322298
```{rust,ignore}
323-
// in src/main.rs
324-
325299
extern crate phrases;
326300
327301
fn main() {
@@ -333,28 +307,20 @@ fn main() {
333307
In our `src/lib.rs`, let's add `pub` to the `english` module declaration:
334308
335309
```{rust,ignore}
336-
// in src/lib.rs
337-
338310
pub mod english;
339-
340311
mod japanese;
341312
```
342313
343314
And in our `src/english/mod.rs`, let's make both `pub`:
344315
345316
```{rust,ignore}
346-
// in src/english/mod.rs
347-
348317
pub mod greetings;
349-
350318
pub mod farewells;
351319
```
352320
353321
In our `src/english/greetings.rs`, let's add `pub` to our `fn` declaration:
354322
355323
```{rust,ignore}
356-
// in src/english/greetings.rs
357-
358324
pub fn hello() -> String {
359325
"Hello!".to_string()
360326
}
@@ -363,8 +329,6 @@ pub fn hello() -> String {
363329
And also in `src/english/farewells.rs`:
364330
365331
```{rust,ignore}
366-
// in src/english/farewells.rs
367-
368332
pub fn goodbye() -> String {
369333
"Goodbye.".to_string()
370334
}
@@ -400,8 +364,6 @@ Rust has a `use` keyword, which allows us to import names into our local scope.
400364
Let's change our `src/main.rs` to look like this:
401365
402366
```{rust,ignore}
403-
// in src/main.rs
404-
405367
extern crate phrases;
406368

407369
use phrases::english::greetings;
@@ -460,21 +422,19 @@ Could not compile `phrases`.
460422
```
461423
462424
If we're importing multiple names from the same module, we don't have to type it out
463-
twice. Rust has a shortcut syntax for writing this:
425+
twice. Instead of this:
464426
465427
```{rust,ignore}
466428
use phrases::english::greetings;
467429
use phrases::english::farewells;
468430
```
469431
470-
You use curly braces:
432+
We can use this shortcut:
471433
472434
```{rust,ignore}
473435
use phrases::english::{greetings, farewells};
474436
```
475437
476-
These two declarations are equivalent, but the second is a lot less typing.
477-
478438
## Re-exporting with `pub use`
479439
480440
You don't just use `use` to shorten identifiers. You can also use it inside of your crate
@@ -484,8 +444,6 @@ interface that may not directly map to your internal code organization.
484444
Let's look at an example. Modify your `src/main.rs` to read like this:
485445
486446
```{rust,ignore}
487-
// in src/main.rs
488-
489447
extern crate phrases;
490448
491449
use phrases::english::{greetings,farewells};
@@ -503,18 +461,13 @@ fn main() {
503461
Then, modify your `src/lib.rs` to make the `japanese` mod public:
504462
505463
```{rust,ignore}
506-
// in src/lib.rs
507-
508464
pub mod english;
509-
510465
pub mod japanese;
511466
```
512467
513468
Next, make the two functions public, first in `src/japanese/greetings.rs`:
514469
515470
```{rust,ignore}
516-
// in src/japanese/greetings.rs
517-
518471
pub fn hello() -> String {
519472
"こんにちは".to_string()
520473
}
@@ -523,8 +476,6 @@ pub fn hello() -> String {
523476
And then in `src/japanese/farewells.rs`:
524477
525478
```{rust,ignore}
526-
// in src/japanese/farewells.rs
527-
528479
pub fn goodbye() -> String {
529480
"さようなら".to_string()
530481
}
@@ -533,13 +484,10 @@ pub fn goodbye() -> String {
533484
Finally, modify your `src/japanese/mod.rs` to read like this:
534485
535486
```{rust,ignore}
536-
// in src/japanese/mod.rs
537-
538487
pub use self::greetings::hello;
539488
pub use self::farewells::goodbye;
540489
541490
mod greetings;
542-
543491
mod farewells;
544492
```
545493

0 commit comments

Comments
 (0)