Skip to content

Commit 02aa428

Browse files
authored
Auto merge of #37657 - steveklabnik:rollup, r=steveklabnik
Rollup of 8 pull requests - Successful merges: #35102, #37425, #37483, #37588, #37601, #37610, #37650, #37652 - Failed merges:
2 parents 966c700 + 5c92c2c commit 02aa428

File tree

9 files changed

+621
-147
lines changed

9 files changed

+621
-147
lines changed

src/doc/book/getting-started.md

+12-99
Original file line numberDiff line numberDiff line change
@@ -4,112 +4,25 @@ This first chapter of the book will get us going with Rust and its tooling.
44
First, we’ll install Rust. Then, the classic ‘Hello World’ program. Finally,
55
we’ll talk about Cargo, Rust’s build system and package manager.
66

7+
We’ll be showing off a number of commands using a terminal, and those lines all
8+
start with `$`. You don't need to type in the `$`s, they are there to indicate
9+
the start of each command. We’ll see many tutorials and examples around the web
10+
that follow this convention: `$` for commands run as our regular user, and `#`
11+
for commands we should be running as an administrator.
12+
713
# Installing Rust
814

915
The first step to using Rust is to install it. Generally speaking, you’ll need
1016
an Internet connection to run the commands in this section, as we’ll be
1117
downloading Rust from the Internet.
1218

13-
We’ll be showing off a number of commands using a terminal, and those lines all
14-
start with `$`. You don't need to type in the `$`s, they are there to indicate
15-
the start of each command. We’ll see many tutorials and examples around the web
16-
that follow this convention: `$` for commands run as our regular user, and `#`
17-
for commands we should be running as an administrator.
19+
The Rust compiler runs on, and compiles to, a great number of platforms, but is
20+
best supported on Linux, Mac, and Windows, on the x86 and x86-64 CPU
21+
architecture. There are official builds of the Rust compiler and standard
22+
library for these platforms and more. [For full details on Rust platform support
23+
see the website][platform-support].
1824

19-
## Platform support
20-
21-
The Rust compiler runs on, and compiles to, a great number of platforms, though
22-
not all platforms are equally supported. Rust's support levels are organized
23-
into three tiers, each with a different set of guarantees.
24-
25-
Platforms are identified by their "target triple" which is the string to inform
26-
the compiler what kind of output should be produced. The columns below indicate
27-
whether the corresponding component works on the specified platform.
28-
29-
### Tier 1
30-
31-
Tier 1 platforms can be thought of as "guaranteed to build and work".
32-
Specifically they will each satisfy the following requirements:
33-
34-
* Automated testing is set up to run tests for the platform.
35-
* Landing changes to the `rust-lang/rust` repository's master branch is gated on
36-
tests passing.
37-
* Official release artifacts are provided for the platform.
38-
* Documentation for how to use and how to build the platform is available.
39-
40-
| Target | std |rustc|cargo| notes |
41-
|-------------------------------|-----|-----|-----|----------------------------|
42-
| `i686-apple-darwin` |||| 32-bit OSX (10.7+, Lion+) |
43-
| `i686-pc-windows-gnu` |||| 32-bit MinGW (Windows 7+) |
44-
| `i686-pc-windows-msvc` |||| 32-bit MSVC (Windows 7+) |
45-
| `i686-unknown-linux-gnu` |||| 32-bit Linux (2.6.18+) |
46-
| `x86_64-apple-darwin` |||| 64-bit OSX (10.7+, Lion+) |
47-
| `x86_64-pc-windows-gnu` |||| 64-bit MinGW (Windows 7+) |
48-
| `x86_64-pc-windows-msvc` |||| 64-bit MSVC (Windows 7+) |
49-
| `x86_64-unknown-linux-gnu` |||| 64-bit Linux (2.6.18+) |
50-
51-
### Tier 2
52-
53-
Tier 2 platforms can be thought of as "guaranteed to build". Automated tests
54-
are not run so it's not guaranteed to produce a working build, but platforms
55-
often work to quite a good degree and patches are always welcome! Specifically,
56-
these platforms are required to have each of the following:
57-
58-
* Automated building is set up, but may not be running tests.
59-
* Landing changes to the `rust-lang/rust` repository's master branch is gated on
60-
platforms **building**. Note that this means for some platforms only the
61-
standard library is compiled, but for others the full bootstrap is run.
62-
* Official release artifacts are provided for the platform.
63-
64-
| Target | std |rustc|cargo| notes |
65-
|-------------------------------|-----|-----|-----|----------------------------|
66-
| `aarch64-apple-ios` || | | ARM64 iOS |
67-
| `aarch64-unknown-linux-gnu` |||| ARM64 Linux (2.6.18+) |
68-
| `arm-linux-androideabi` || | | ARM Android |
69-
| `arm-unknown-linux-gnueabi` |||| ARM Linux (2.6.18+) |
70-
| `arm-unknown-linux-gnueabihf` |||| ARM Linux (2.6.18+) |
71-
| `armv7-apple-ios` || | | ARM iOS |
72-
|`armv7-unknown-linux-gnueabihf`|||| ARMv7 Linux (2.6.18+) |
73-
| `armv7s-apple-ios` || | | ARM iOS |
74-
| `i386-apple-ios` || | | 32-bit x86 iOS |
75-
| `i586-pc-windows-msvc` || | | 32-bit Windows w/o SSE |
76-
| `mips-unknown-linux-gnu` || | | MIPS Linux (2.6.18+) |
77-
| `mips-unknown-linux-musl` || | | MIPS Linux with MUSL |
78-
| `mipsel-unknown-linux-gnu` || | | MIPS (LE) Linux (2.6.18+) |
79-
| `mipsel-unknown-linux-musl` || | | MIPS (LE) Linux with MUSL |
80-
| `powerpc-unknown-linux-gnu` || | | PowerPC Linux (2.6.18+) |
81-
| `powerpc64-unknown-linux-gnu` || | | PPC64 Linux (2.6.18+) |
82-
|`powerpc64le-unknown-linux-gnu`|| | | PPC64LE Linux (2.6.18+) |
83-
| `x86_64-apple-ios` || | | 64-bit x86 iOS |
84-
| `x86_64-rumprun-netbsd` || | | 64-bit NetBSD Rump Kernel |
85-
| `x86_64-unknown-freebsd` |||| 64-bit FreeBSD |
86-
| `x86_64-unknown-linux-musl` || | | 64-bit Linux with MUSL |
87-
| `x86_64-unknown-netbsd` |||| 64-bit NetBSD |
88-
89-
### Tier 3
90-
91-
Tier 3 platforms are those which Rust has support for, but landing changes is
92-
not gated on the platform either building or passing tests. Working builds for
93-
these platforms may be spotty as their reliability is often defined in terms of
94-
community contributions. Additionally, release artifacts and installers are not
95-
provided, but there may be community infrastructure producing these in
96-
unofficial locations.
97-
98-
| Target | std |rustc|cargo| notes |
99-
|-------------------------------|-----|-----|-----|----------------------------|
100-
| `aarch64-linux-android` || | | ARM64 Android |
101-
| `armv7-linux-androideabi` || | | ARM-v7a Android |
102-
| `i686-linux-android` || | | 32-bit x86 Android |
103-
| `i686-pc-windows-msvc` (XP) || | | Windows XP support |
104-
| `i686-unknown-freebsd` |||| 32-bit FreeBSD |
105-
| `x86_64-pc-windows-msvc` (XP) || | | Windows XP support |
106-
| `x86_64-sun-solaris` ||| | 64-bit Solaris/SunOS |
107-
| `x86_64-unknown-bitrig` ||| | 64-bit Bitrig |
108-
| `x86_64-unknown-dragonfly` ||| | 64-bit DragonFlyBSD |
109-
| `x86_64-unknown-openbsd` ||| | 64-bit OpenBSD |
110-
111-
Note that this table can be expanded over time, this isn't the exhaustive set of
112-
tier 3 platforms that will ever be!
25+
[platform-support]: https://forge.rust-lang.org/platform-support.html
11326

11427
## Installing on Linux or Mac
11528

src/doc/book/guessing-game.md

+43-23
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ has a command that does that for us. Let’s give it a shot:
1919
```bash
2020
$ cd ~/projects
2121
$ cargo new guessing_game --bin
22+
Created binary (application) `guessing_game` project
2223
$ cd guessing_game
2324
```
2425

@@ -51,6 +52,7 @@ Let’s try compiling what Cargo gave us:
5152
```{bash}
5253
$ cargo build
5354
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
55+
Finished debug [unoptimized + debuginfo] target(s) in 0.53 secs
5456
```
5557

5658
Excellent! Open up your `src/main.rs` again. We’ll be writing all of
@@ -61,6 +63,7 @@ Remember the `run` command from last chapter? Try it out again here:
6163
```bash
6264
$ cargo run
6365
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
66+
Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
6467
Running `target/debug/guessing_game`
6568
Hello, world!
6669
```
@@ -282,10 +285,13 @@ we’ll get a warning:
282285
```bash
283286
$ cargo build
284287
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
285-
src/main.rs:10:5: 10:39 warning: unused result which must be used,
286-
#[warn(unused_must_use)] on by default
287-
src/main.rs:10 io::stdin().read_line(&mut guess);
288-
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288+
warning: unused result which must be used, #[warn(unused_must_use)] on by default
289+
--> src/main.rs:10:5
290+
|
291+
10 | io::stdin().read_line(&mut guess);
292+
| ^
293+
294+
Finished debug [unoptimized + debuginfo] target(s) in 0.42 secs
289295
```
290296

291297
Rust warns us that we haven’t used the `Result` value. This warning comes from
@@ -321,6 +327,7 @@ Anyway, that’s the tour. We can run what we have with `cargo run`:
321327
```bash
322328
$ cargo run
323329
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
330+
Finished debug [unoptimized + debuginfo] target(s) in 0.44 secs
324331
Running `target/debug/guessing_game`
325332
Guess the number!
326333
Please input your guess.
@@ -373,11 +380,12 @@ Now, without changing any of our code, let’s build our project:
373380
```bash
374381
$ cargo build
375382
Updating registry `https://github.com/rust-lang/crates.io-index`
376-
Downloading rand v0.3.8
377-
Downloading libc v0.1.6
378-
Compiling libc v0.1.6
379-
Compiling rand v0.3.8
383+
Downloading rand v0.3.14
384+
Downloading libc v0.2.17
385+
Compiling libc v0.2.17
386+
Compiling rand v0.3.14
380387
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
388+
Finished debug [unoptimized + debuginfo] target(s) in 5.88 secs
381389
```
382390

383391
(You may see different versions, of course.)
@@ -399,22 +407,24 @@ If we run `cargo build` again, we’ll get different output:
399407

400408
```bash
401409
$ cargo build
410+
Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
402411
```
403412

404-
That’s right, no output! Cargo knows that our project has been built, and that
413+
That’s right, nothing was done! Cargo knows that our project has been built, and that
405414
all of its dependencies are built, and so there’s no reason to do all that
406415
stuff. With nothing to do, it simply exits. If we open up `src/main.rs` again,
407-
make a trivial change, and then save it again, we’ll only see one line:
416+
make a trivial change, and then save it again, we’ll only see two lines:
408417

409418
```bash
410419
$ cargo build
411420
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
421+
Finished debug [unoptimized + debuginfo] target(s) in 0.45 secs
412422
```
413423

414424
So, we told Cargo we wanted any `0.3.x` version of `rand`, and so it fetched the latest
415-
version at the time this was written, `v0.3.8`. But what happens when next
416-
week, version `v0.3.9` comes out, with an important bugfix? While getting
417-
bugfixes is important, what if `0.3.9` contains a regression that breaks our
425+
version at the time this was written, `v0.3.14`. But what happens when next
426+
week, version `v0.3.15` comes out, with an important bugfix? While getting
427+
bugfixes is important, what if `0.3.15` contains a regression that breaks our
418428
code?
419429

420430
The answer to this problem is the `Cargo.lock` file you’ll now find in your
@@ -423,11 +433,11 @@ figures out all of the versions that fit your criteria, and then writes them
423433
to the `Cargo.lock` file. When you build your project in the future, Cargo
424434
will see that the `Cargo.lock` file exists, and then use that specific version
425435
rather than do all the work of figuring out versions again. This lets you
426-
have a repeatable build automatically. In other words, we’ll stay at `0.3.8`
436+
have a repeatable build automatically. In other words, we’ll stay at `0.3.14`
427437
until we explicitly upgrade, and so will anyone who we share our code with,
428438
thanks to the lock file.
429439

430-
What about when we _do_ want to use `v0.3.9`? Cargo has another command,
440+
What about when we _do_ want to use `v0.3.15`? Cargo has another command,
431441
`update`, which says ‘ignore the lock, figure out all the latest versions that
432442
fit what we’ve specified. If that works, write those versions out to the lock
433443
file’. But, by default, Cargo will only look for versions larger than `0.3.0`
@@ -510,13 +520,15 @@ Try running our new program a few times:
510520
```bash
511521
$ cargo run
512522
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
523+
Finished debug [unoptimized + debuginfo] target(s) in 0.55 secs
513524
Running `target/debug/guessing_game`
514525
Guess the number!
515526
The secret number is: 7
516527
Please input your guess.
517528
4
518529
You guessed: 4
519530
$ cargo run
531+
Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
520532
Running `target/debug/guessing_game`
521533
Guess the number!
522534
The secret number is: 83
@@ -618,15 +630,20 @@ I did mention that this won’t quite compile yet, though. Let’s try it:
618630
```bash
619631
$ cargo build
620632
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
621-
src/main.rs:28:21: 28:35 error: mismatched types:
622-
expected `&collections::string::String`,
623-
found `&_`
624-
(expected struct `collections::string::String`,
625-
found integral variable) [E0308]
626-
src/main.rs:28 match guess.cmp(&secret_number) {
627-
^~~~~~~~~~~~~~
633+
error[E0308]: mismatched types
634+
--> src/main.rs:23:21
635+
|
636+
23 | match guess.cmp(&secret_number) {
637+
| ^^^^^^^^^^^^^^ expected struct `std::string::String`, found integral variable
638+
|
639+
= note: expected type `&std::string::String`
640+
= note: found type `&{integer}`
641+
628642
error: aborting due to previous error
629-
Could not compile `guessing_game`.
643+
644+
error: Could not compile `guessing_game`.
645+
646+
To learn more, run the command again with --verbose.
630647
```
631648
632649
Whew! This is a big error. The core of it is that we have ‘mismatched types’.
@@ -722,6 +739,7 @@ Let’s try our program out!
722739
```bash
723740
$ cargo run
724741
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
742+
Finished debug [unoptimized + debuginfo] target(s) in 0.57 secs
725743
Running `target/guessing_game`
726744
Guess the number!
727745
The secret number is: 58
@@ -785,6 +803,7 @@ and quit. Observe:
785803
```bash
786804
$ cargo run
787805
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
806+
Finished debug [unoptimized + debuginfo] target(s) in 0.58 secs
788807
Running `target/guessing_game`
789808
Guess the number!
790809
The secret number is: 59
@@ -919,6 +938,7 @@ Now we should be good! Let’s try:
919938
```bash
920939
$ cargo run
921940
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
941+
Finished debug [unoptimized + debuginfo] target(s) in 0.57 secs
922942
Running `target/guessing_game`
923943
Guess the number!
924944
The secret number is: 61

src/doc/book/structs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ write something like this:
6161

6262
```rust,ignore
6363
struct Point {
64-
mut x: i32,
64+
mut x: i32, // This causes an error.
6565
y: i32,
6666
}
6767
```

src/doc/reference.md

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ separately by extracting documentation attributes from their source code. Many
2121
of the features that one might expect to be language features are library
2222
features in Rust, so what you're looking for may be there, not here.
2323

24+
Finally, this document is not normative. It may include details that are
25+
specific to `rustc` itself, and should not be taken as a specification for
26+
the Rust language. We intend to produce such a document someday, but this
27+
is what we have for now.
28+
2429
You may also be interested in the [grammar].
2530

2631
[book]: book/index.html

src/liballoc/arc.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,14 @@ impl<T: ?Sized> Arc<T> {
381381

382382
/// Gets the number of [`Weak`][weak] pointers to this value.
383383
///
384-
/// Be careful how you use this information, because another thread
385-
/// may change the weak count at any time.
386-
///
387384
/// [weak]: struct.Weak.html
388385
///
386+
/// # Safety
387+
///
388+
/// This method by itself is safe, but using it correctly requires extra care.
389+
/// Another thread can change the weak count at any time,
390+
/// including potentially between calling this method and acting on the result.
391+
///
389392
/// # Examples
390393
///
391394
/// ```
@@ -409,8 +412,11 @@ impl<T: ?Sized> Arc<T> {
409412

410413
/// Gets the number of strong (`Arc`) pointers to this value.
411414
///
412-
/// Be careful how you use this information, because another thread
413-
/// may change the strong count at any time.
415+
/// # Safety
416+
///
417+
/// This method by itself is safe, but using it correctly requires extra care.
418+
/// Another thread can change the strong count at any time,
419+
/// including potentially between calling this method and acting on the result.
414420
///
415421
/// # Examples
416422
///

src/libcore/iter/traits.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,14 @@ impl<'a, I: ExactSizeIterator + ?Sized> ExactSizeIterator for &'a mut I {}
556556

557557
/// Trait to represent types that can be created by summing up an iterator.
558558
///
559-
/// This trait is used to implement the `sum` method on iterators. Types which
560-
/// implement the trait can be generated by the `sum` method. Like
561-
/// `FromIterator` this trait should rarely be called directly and instead
562-
/// interacted with through `Iterator::sum`.
559+
/// This trait is used to implement the [`sum()`] method on iterators. Types which
560+
/// implement the trait can be generated by the [`sum()`] method. Like
561+
/// [`FromIterator`] this trait should rarely be called directly and instead
562+
/// interacted with through [`Iterator::sum()`].
563+
///
564+
/// [`sum()`]: ../../std/iter/trait.Sum.html#tymethod.sum
565+
/// [`FromIterator`]: ../../std/iter/trait.FromIterator.html
566+
/// [`Iterator::sum()`]: ../../std/iter/trait.Iterator.html#method.sum
563567
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
564568
pub trait Sum<A = Self>: Sized {
565569
/// Method which takes an iterator and generates `Self` from the elements by
@@ -571,10 +575,14 @@ pub trait Sum<A = Self>: Sized {
571575
/// Trait to represent types that can be created by multiplying elements of an
572576
/// iterator.
573577
///
574-
/// This trait is used to implement the `product` method on iterators. Types
575-
/// which implement the trait can be generated by the `product` method. Like
576-
/// `FromIterator` this trait should rarely be called directly and instead
577-
/// interacted with through `Iterator::product`.
578+
/// This trait is used to implement the [`product()`] method on iterators. Types
579+
/// which implement the trait can be generated by the [`product()`] method. Like
580+
/// [`FromIterator`] this trait should rarely be called directly and instead
581+
/// interacted with through [`Iterator::product()`].
582+
///
583+
/// [`product()`]: ../../std/iter/trait.Product.html#tymethod.product
584+
/// [`FromIterator`]: ../../std/iter/trait.FromIterator.html
585+
/// [`Iterator::product()`]: ../../std/iter/trait.Iterator.html#method.product
578586
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
579587
pub trait Product<A = Self>: Sized {
580588
/// Method which takes an iterator and generates `Self` from the elements by

0 commit comments

Comments
 (0)