Skip to content

Commit 16b7893

Browse files
committed
---
yaml --- r: 192187 b: refs/heads/master c: bc1dde4 h: refs/heads/master i: 192185: 5e4e386 192183: 04950ea v: v3
1 parent 8e257d5 commit 16b7893

File tree

126 files changed

+768
-2052
lines changed

Some content is hidden

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

126 files changed

+768
-2052
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: 388e5aee1e3df9e25f69815ffebfaa39e2167b5f
2+
refs/heads/master: bc1dde468c1613743c919cb9f33923cc9916c5b4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a923278c6278c63468d74772c58dbf788e88f58c
55
refs/heads/try: ce76bff75603a754d092456285ff455eb871633d

trunk/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"),

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::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
}

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

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

trunk/src/doc/trpl/compound-data-types.md

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This pattern is very powerful, and we'll see it repeated more later.
4747

4848
There are also a few things you can do with a tuple as a whole, without
4949
destructuring. You can assign one tuple into another, if they have the same
50-
contained types and [arity]. Tuples have the same arity when they have the same
50+
contained types and arity. Tuples have the same arity when they have the same
5151
length.
5252

5353
```rust
@@ -196,9 +196,8 @@ Now, we have actual names, rather than positions. Good names are important,
196196
and with a struct, we have actual names.
197197

198198
There _is_ one case when a tuple struct is very useful, though, and that's a
199-
tuple struct with only one element. We call this the *newtype* pattern, because
200-
it allows you to create a new type, distinct from that of its contained value
201-
and expressing its own semantic meaning:
199+
tuple struct with only one element. We call this a *newtype*, because it lets
200+
you create a new type that's similar to another one:
202201

203202
```{rust}
204203
struct Inches(i32);
@@ -217,7 +216,7 @@ destructuring `let`, as we discussed previously in 'tuples.' In this case, the
217216

218217
Finally, Rust has a "sum type", an *enum*. Enums are an incredibly useful
219218
feature of Rust, and are used throughout the standard library. An `enum` is
220-
a type which relates a set of alternates to a specific name. For example, below
219+
a type which ties a set of alternates to a specific name. For example, below
221220
we define `Character` to be either a `Digit` or something else. These
222221
can be used via their fully scoped names: `Character::Other` (more about `::`
223222
below).
@@ -229,8 +228,8 @@ enum Character {
229228
}
230229
```
231230

232-
Most normal types are allowed as the variant components of an `enum`. Here are
233-
some examples:
231+
An `enum` variant can be defined as most normal types. Below are some example
232+
types which also would be allowed in an `enum`.
234233

235234
```rust
236235
struct Empty;
@@ -240,15 +239,15 @@ struct Status { Health: i32, Mana: i32, Attack: i32, Defense: i32 }
240239
struct HeightDatabase(Vec<i32>);
241240
```
242241

243-
You see that, depending on its type, an `enum` variant may or may not hold data.
244-
In `Character`, for instance, `Digit` gives a meaningful name for an `i32`
245-
value, where `Other` is only a name. However, the fact that they represent
246-
distinct categories of `Character` is a very useful property.
242+
So you see that depending on the sub-datastructure, the `enum` variant, same as
243+
a struct, may or may not hold data. That is, in `Character`, `Digit` is a name
244+
tied to an `i32` where `Other` is just a name. However, the fact that they are
245+
distinct makes this very useful.
247246

248-
As with structures, the variants of an enum by default are not comparable with
249-
equality operators (`==`, `!=`), have no ordering (`<`, `>=`, etc.), and do not
250-
support other binary operations such as `*` and `+`. As such, the following code
251-
is invalid for the example `Character` type:
247+
As with structures, enums don't by default have access to operators such as
248+
compare ( `==` and `!=`), binary operations (`*` and `+`), and order
249+
(`<` and `>=`). As such, using the previous `Character` type, the
250+
following code is invalid:
252251

253252
```{rust,ignore}
254253
// These assignments both succeed
@@ -266,10 +265,9 @@ let four_equals_ten = four == ten;
266265
```
267266

268267
This may seem rather limiting, but it's a limitation which we can overcome.
269-
There are two ways: by implementing equality ourselves, or by pattern matching
270-
variants with [`match`][match] expressions, which you'll learn in the next
271-
chapter. We don't know enough about Rust to implement equality yet, but we can
272-
use the `Ordering` enum from the standard library, which does:
268+
There are two ways: by implementing equality ourselves, or by using the
269+
[`match`][match] keyword. We don't know enough about Rust to implement equality
270+
yet, but we can use the `Ordering` enum from the standard library, which does:
273271

274272
```
275273
enum Ordering {
@@ -279,8 +277,9 @@ enum Ordering {
279277
}
280278
```
281279

282-
Because `Ordering` has already been defined for us, we will import it with the
283-
`use` keyword. Here's an example of how it is used:
280+
Because we did not define `Ordering`, we must import it (from the std
281+
library) with the `use` keyword. Here's an example of how `Ordering` is
282+
used:
284283

285284
```{rust}
286285
use std::cmp::Ordering;
@@ -314,17 +313,17 @@ the standard library if you need them.
314313

315314
Okay, let's talk about the actual code in the example. `cmp` is a function that
316315
compares two things, and returns an `Ordering`. We return either
317-
`Ordering::Less`, `Ordering::Greater`, or `Ordering::Equal`, depending on
318-
whether the first value is less than, greater than, or equal to the second. Note
319-
that each variant of the `enum` is namespaced under the `enum` itself: it's
320-
`Ordering::Greater`, not `Greater`.
316+
`Ordering::Less`, `Ordering::Greater`, or `Ordering::Equal`, depending on if
317+
the two values are less, greater, or equal. Note that each variant of the
318+
`enum` is namespaced under the `enum` itself: it's `Ordering::Greater` not
319+
`Greater`.
321320

322321
The `ordering` variable has the type `Ordering`, and so contains one of the
323322
three values. We then do a bunch of `if`/`else` comparisons to check which
324323
one it is.
325324

326-
This `Ordering::Greater` notation is too long. Let's use another form of `use`
327-
to import the `enum` variants instead. This will avoid full scoping:
325+
This `Ordering::Greater` notation is too long. Let's use `use` to import the
326+
`enum` variants instead. This will avoid full scoping:
328327

329328
```{rust}
330329
use std::cmp::Ordering::{self, Equal, Less, Greater};
@@ -348,18 +347,16 @@ fn main() {
348347
```
349348

350349
Importing variants is convenient and compact, but can also cause name conflicts,
351-
so do this with caution. For this reason, it's normally considered better style
352-
to `use` an enum rather than its variants directly.
350+
so do this with caution. It's considered good style to rarely import variants
351+
for this reason.
353352

354-
As you can see, `enum`s are quite a powerful tool for data representation, and
355-
are even more useful when they're [generic][generics] across types. Before we
356-
get to generics, though, let's talk about how to use enums with pattern
357-
matching, a tool that will let us deconstruct sum types (the type theory term
358-
for enums) like `Ordering` in a very elegant way that avoids all these messy
359-
and brittle `if`/`else`s.
353+
As you can see, `enum`s are quite a powerful tool for data representation, and are
354+
even more useful when they're [generic][generics] across types. Before we
355+
get to generics, though, let's talk about how to use them with pattern matching, a
356+
tool that will let us deconstruct this sum type (the type theory term for enums)
357+
in a very elegant way and avoid all these messy `if`/`else`s.
360358

361359

362-
[arity]: ./glossary.html#arity
363360
[match]: ./match.html
364361
[game]: ./guessing-game.html#comparing-guesses
365362
[generics]: ./generics.html

trunk/src/doc/trpl/concurrency.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ us enforce that it can't leave the current thread.
4040

4141
### `Sync`
4242

43-
The second of these traits is called [`Sync`](../std/marker/trait.Sync.html).
43+
The second of these two trait is called [`Sync`](../std/marker/trait.Sync.html).
4444
When a type `T` implements `Sync`, it indicates to the compiler that something
4545
of this type has no possibility of introducing memory unsafety when used from
4646
multiple threads concurrently.
4747

4848
For example, sharing immutable data with an atomic reference count is
4949
threadsafe. Rust provides a type like this, `Arc<T>`, and it implements `Sync`,
50-
so it is safe to share between threads.
50+
so that it could be safely shared between threads.
5151

5252
These two traits allow you to use the type system to make strong guarantees
5353
about the properties of your code under concurrency. Before we demonstrate
@@ -69,7 +69,7 @@ fn main() {
6969
}
7070
```
7171

72-
The `thread::scoped()` method accepts a closure, which is executed in a new
72+
The `Thread::scoped()` method accepts a closure, which is executed in a new
7373
thread. It's called `scoped` because this thread returns a join guard:
7474

7575
```
@@ -208,10 +208,10 @@ Here's the error:
208208

209209
```text
210210
<anon>:11:9: 11:22 error: the trait `core::marker::Send` is not implemented for the type `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` [E0277]
211-
<anon>:11 thread::spawn(move || {
211+
<anon>:11 Thread::spawn(move || {
212212
^~~~~~~~~~~~~
213213
<anon>:11:9: 11:22 note: `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` cannot be sent between threads safely
214-
<anon>:11 thread::spawn(move || {
214+
<anon>:11 Thread::spawn(move || {
215215
^~~~~~~~~~~~~
216216
```
217217

@@ -322,6 +322,7 @@ While this channel is just sending a generic signal, we can send any data that
322322
is `Send` over the channel!
323323

324324
```
325+
use std::sync::{Arc, Mutex};
325326
use std::thread;
326327
use std::sync::mpsc;
327328

0 commit comments

Comments
 (0)