Skip to content

Commit efb5a9a

Browse files
committed
Auto merge of #30640 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #30373, #30502, #30511, #30546, #30556, #30620 - Failed merges:
2 parents 85fb3b6 + a73df6b commit efb5a9a

File tree

9 files changed

+82
-54
lines changed

9 files changed

+82
-54
lines changed

.gitmodules

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
url = https://github.com/rust-lang/jemalloc.git
1414
[submodule "src/rust-installer"]
1515
path = src/rust-installer
16-
url = https://github.com/rust-lang/rust-installer
16+
url = https://github.com/rust-lang/rust-installer.git
1717
[submodule "src/liblibc"]
1818
path = src/liblibc
19-
url = https://github.com/rust-lang/libc
19+
url = https://github.com/rust-lang-nursery/libc.git

src/doc/book/choosing-your-guarantees.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,11 @@ With the former, the `RefCell<T>` is wrapping the `Vec<T>`, so the `Vec<T>` in i
340340
mutable. At the same time, there can only be one mutable borrow of the whole `Vec` at a given time.
341341
This means that your code cannot simultaneously work on different elements of the vector from
342342
different `Rc` handles. However, we are able to push and pop from the `Vec<T>` at will. This is
343-
similar to an `&mut Vec<T>` with the borrow checking done at runtime.
343+
similar to a `&mut Vec<T>` with the borrow checking done at runtime.
344344

345345
With the latter, the borrowing is of individual elements, but the overall vector is immutable. Thus,
346346
we can independently borrow separate elements, but we cannot push or pop from the vector. This is
347-
similar to an `&mut [T]`[^3], but, again, the borrow checking is at runtime.
347+
similar to a `&mut [T]`[^3], but, again, the borrow checking is at runtime.
348348

349349
In concurrent programs, we have a similar situation with `Arc<Mutex<T>>`, which provides shared
350350
mutability and ownership.

src/doc/book/documentation.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ hello.rs:4 }
7373
```
7474

7575
This [unfortunate error](https://github.com/rust-lang/rust/issues/22547) is
76-
correct: documentation comments apply to the thing after them, and there's
76+
correct; documentation comments apply to the thing after them, and there's
7777
nothing after that last comment.
7878

7979
[rc-new]: https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.new
@@ -385,7 +385,7 @@ error handling. Lets say you want the following,
385385

386386
```rust,ignore
387387
/// use std::io;
388-
/// let mut input = String::new();
388+
/// let mut input = String::new();
389389
/// try!(io::stdin().read_line(&mut input));
390390
```
391391

@@ -398,7 +398,7 @@ don't return anything so this will give a mismatched types error.
398398
/// ```
399399
/// use std::io;
400400
/// # fn foo() -> io::Result<()> {
401-
/// let mut input = String::new();
401+
/// let mut input = String::new();
402402
/// try!(io::stdin().read_line(&mut input));
403403
/// # Ok(())
404404
/// # }

src/doc/book/lifetimes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Then in our parameter list, we use the lifetimes we’ve named:
103103
...(x: &'a i32)
104104
```
105105

106-
If we wanted an `&mut` reference, we’d do this:
106+
If we wanted a `&mut` reference, we’d do this:
107107

108108
```rust,ignore
109109
...(x: &'a mut i32)

src/doc/book/match.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,24 @@ match x {
2323
`match` takes an expression and then branches based on its value. Each ‘arm’ of
2424
the branch is of the form `val => expression`. When the value matches, that arm’s
2525
expression will be evaluated. It’s called `match` because of the term ‘pattern
26-
matching’, which `match` is an implementation of. There’s an [entire section on
26+
matching’, which `match` is an implementation of. There’s a [separate section on
2727
patterns][patterns] that covers all the patterns that are possible here.
2828

2929
[patterns]: patterns.html
3030

31-
So what’s the big advantage? Well, there are a few. First of all, `match`
32-
enforces ‘exhaustiveness checking’. Do you see that last arm, the one with the
33-
underscore (`_`)? If we remove that arm, Rust will give us an error:
31+
One of the many advantages of `match` is it enforces ‘exhaustiveness checking’.
32+
For example if we remove the last arm with the underscore `_`, the compiler will
33+
give us an error:
3434

3535
```text
3636
error: non-exhaustive patterns: `_` not covered
3737
```
3838

39-
In other words, Rust is trying to tell us we forgot a value. Because `x` is an
40-
integer, Rust knows that it can have a number of different values – for
41-
example, `6`. Without the `_`, however, there is no arm that could match, and
42-
so Rust refuses to compile the code. `_` acts like a ‘catch-all arm’. If none
43-
of the other arms match, the arm with `_` will, and since we have this
44-
catch-all arm, we now have an arm for every possible value of `x`, and so our
45-
program will compile successfully.
39+
Rust is telling us that we forgot a value. The compiler infers from `x` that it
40+
can have any positive 32bit value; for example 1 to 2,147,483,647. The `_` acts
41+
as a 'catch-all', and will catch all possible values that *aren't* specified in
42+
an arm of `match`. As you can see with the previous example, we provide `match`
43+
arms for integers 1-5, if `x` is 6 or any other value, then it is caught by `_`.
4644

4745
`match` is also an expression, which means we can use it on the right-hand
4846
side of a `let` binding or directly where an expression is used:
@@ -60,7 +58,8 @@ let number = match x {
6058
};
6159
```
6260

63-
Sometimes it’s a nice way of converting something from one type to another.
61+
Sometimes it’s a nice way of converting something from one type to another; in
62+
this example the integers are converted to `String`.
6463

6564
# Matching on enums
6665

@@ -91,7 +90,8 @@ fn process_message(msg: Message) {
9190

9291
Again, the Rust compiler checks exhaustiveness, so it demands that you
9392
have a match arm for every variant of the enum. If you leave one off, it
94-
will give you a compile-time error unless you use `_`.
93+
will give you a compile-time error unless you use `_` or provide all possible
94+
arms.
9595

9696
Unlike the previous uses of `match`, you can’t use the normal `if`
9797
statement to do this. You can use the [`if let`][if-let] statement,

src/doc/book/references-and-borrowing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ the thing `y` points at. You’ll notice that `x` had to be marked `mut` as well
126126
If it wasn’t, we couldn’t take a mutable borrow to an immutable value.
127127

128128
You'll also notice we added an asterisk (`*`) in front of `y`, making it `*y`,
129-
this is because `y` is an `&mut` reference. You'll also need to use them for
129+
this is because `y` is a `&mut` reference. You'll also need to use them for
130130
accessing the contents of a reference as well.
131131

132132
Otherwise, `&mut` references are just like references. There _is_ a large

src/libcore/iter.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -1113,16 +1113,22 @@ pub trait Iterator {
11131113
Take{iter: self, n: n}
11141114
}
11151115

1116-
/// An iterator similar to `fold()`, with internal state.
1117-
///
1118-
/// `scan()` accumulates a final value, similar to [`fold()`], but instead
1119-
/// of passing along an accumulator, it maintains the accumulator internally.
1116+
/// An iterator adaptor similar to [`fold()`] that holds internal state and
1117+
/// produces a new iterator.
11201118
///
11211119
/// [`fold()`]: #method.fold
11221120
///
1123-
/// On each iteraton of `scan()`, you can assign to the internal state, and
1124-
/// a mutable reference to the state is passed as the first argument to the
1125-
/// closure, allowing you to modify it on each iteration.
1121+
/// `scan()` takes two arguments: an initial value which seeds the internal
1122+
/// state, and a closure with two arguments, the first being a mutable
1123+
/// reference to the internal state and the second an iterator element.
1124+
/// The closure can assign to the internal state to share state between
1125+
/// iterations.
1126+
///
1127+
/// On iteration, the closure will be applied to each element of the
1128+
/// iterator and the return value from the closure, an [`Option`], is
1129+
/// yielded by the iterator.
1130+
///
1131+
/// [`Option`]: ../option/enum.Option.html
11261132
///
11271133
/// # Examples
11281134
///

src/libstd/io/stdio.rs

+36-15
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,30 @@ fn handle_ebadf<T>(r: io::Result<T>, default: T) -> io::Result<T> {
133133
/// A handle to the standard input stream of a process.
134134
///
135135
/// Each handle is a shared reference to a global buffer of input data to this
136-
/// process. A handle can be `lock`'d to gain full access to `BufRead` methods
136+
/// process. A handle can be `lock`'d to gain full access to [`BufRead`] methods
137137
/// (e.g. `.lines()`). Writes to this handle are otherwise locked with respect
138138
/// to other writes.
139139
///
140140
/// This handle implements the `Read` trait, but beware that concurrent reads
141141
/// of `Stdin` must be executed with care.
142142
///
143-
/// Created by the function `io::stdin()`.
143+
/// Created by the [`io::stdin`] method.
144+
///
145+
/// [`io::stdin`]: fn.stdin.html
146+
/// [`BufRead`]: trait.BufRead.html
144147
#[stable(feature = "rust1", since = "1.0.0")]
145148
pub struct Stdin {
146149
inner: Arc<Mutex<BufReader<Maybe<StdinRaw>>>>,
147150
}
148151

149152
/// A locked reference to the `Stdin` handle.
150153
///
151-
/// This handle implements both the `Read` and `BufRead` traits and is
152-
/// constructed via the `lock` method on `Stdin`.
154+
/// This handle implements both the [`Read`] and [`BufRead`] traits, and
155+
/// is constructed via the [`Stdin::lock`] method.
156+
///
157+
/// [`Read`]: trait.Read.html
158+
/// [`BufRead`]: trait.BufRead.html
159+
/// [`Stdin::lock`]: struct.Stdin.html#method.lock
153160
#[stable(feature = "rust1", since = "1.0.0")]
154161
pub struct StdinLock<'a> {
155162
inner: MutexGuard<'a, BufReader<Maybe<StdinRaw>>>,
@@ -159,7 +166,7 @@ pub struct StdinLock<'a> {
159166
///
160167
/// Each handle returned is a reference to a shared global buffer whose access
161168
/// is synchronized via a mutex. If you need more explicit control over
162-
/// locking, see the [lock() method][lock].
169+
/// locking, see the [`lock() method`][lock].
163170
///
164171
/// [lock]: struct.Stdin.html#method.lock
165172
///
@@ -221,8 +228,11 @@ impl Stdin {
221228
/// guard.
222229
///
223230
/// The lock is released when the returned lock goes out of scope. The
224-
/// returned guard also implements the `Read` and `BufRead` traits for
231+
/// returned guard also implements the [`Read`] and [`BufRead`] traits for
225232
/// accessing the underlying data.
233+
///
234+
/// [Read]: trait.Read.html
235+
/// [BufRead]: trait.BufRead.html
226236
#[stable(feature = "rust1", since = "1.0.0")]
227237
pub fn lock(&self) -> StdinLock {
228238
StdinLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) }
@@ -231,7 +241,9 @@ impl Stdin {
231241
/// Locks this handle and reads a line of input into the specified buffer.
232242
///
233243
/// For detailed semantics of this method, see the documentation on
234-
/// `BufRead::read_line`.
244+
/// [`BufRead::read_line`].
245+
///
246+
/// [`BufRead::read_line`]: trait.BufRead.html#method.read_line
235247
///
236248
/// # Examples
237249
///
@@ -314,7 +326,9 @@ const OUT_MAX: usize = ::usize::MAX;
314326
/// output stream. Access is also synchronized via a lock and explicit control
315327
/// over locking is available via the `lock` method.
316328
///
317-
/// Created by the function `io::stdout()`.
329+
/// Created by the [`io::stdout`] method.
330+
///
331+
/// [`io::stdout`]: fn.stdout.html
318332
#[stable(feature = "rust1", since = "1.0.0")]
319333
pub struct Stdout {
320334
// FIXME: this should be LineWriter or BufWriter depending on the state of
@@ -325,8 +339,11 @@ pub struct Stdout {
325339

326340
/// A locked reference to the `Stdout` handle.
327341
///
328-
/// This handle implements the `Write` trait and is constructed via the `lock`
329-
/// method on `Stdout`.
342+
/// This handle implements the [`Write`] trait, and is constructed via
343+
/// the [`Stdout::lock`] method.
344+
///
345+
/// [`Write`]: trait.Write.html
346+
/// [`Stdout::lock`]: struct.Stdout.html#method.lock
330347
#[stable(feature = "rust1", since = "1.0.0")]
331348
pub struct StdoutLock<'a> {
332349
inner: ReentrantMutexGuard<'a, RefCell<LineWriter<Maybe<StdoutRaw>>>>,
@@ -336,9 +353,9 @@ pub struct StdoutLock<'a> {
336353
///
337354
/// Each handle returned is a reference to a shared global buffer whose access
338355
/// is synchronized via a mutex. If you need more explicit control over
339-
/// locking, see the [lock() method][lock].
356+
/// locking, see the [Stdout::lock] method.
340357
///
341-
/// [lock]: struct.Stdout.html#method.lock
358+
/// [Stdout::lock]: struct.Stdout.html#method.lock
342359
///
343360
/// # Examples
344361
///
@@ -424,16 +441,20 @@ impl<'a> Write for StdoutLock<'a> {
424441

425442
/// A handle to the standard error stream of a process.
426443
///
427-
/// For more information, see `stderr`
444+
/// For more information, see the [`io::stderr`] method.
445+
///
446+
/// [`io::stderr`]: fn.stderr.html
428447
#[stable(feature = "rust1", since = "1.0.0")]
429448
pub struct Stderr {
430449
inner: Arc<ReentrantMutex<RefCell<Maybe<StderrRaw>>>>,
431450
}
432451

433452
/// A locked reference to the `Stderr` handle.
434453
///
435-
/// This handle implements the `Write` trait and is constructed via the `lock`
436-
/// method on `Stderr`.
454+
/// This handle implements the `Write` trait and is constructed via
455+
/// the [`Stderr::lock`] method.
456+
///
457+
/// [`Stderr::lock`]: struct.Stderr.html#method.lock
437458
#[stable(feature = "rust1", since = "1.0.0")]
438459
pub struct StderrLock<'a> {
439460
inner: ReentrantMutexGuard<'a, RefCell<Maybe<StderrRaw>>>,

src/libstd/net/udp.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,19 @@ use time::Duration;
2727
/// use std::net::UdpSocket;
2828
///
2929
/// # fn foo() -> std::io::Result<()> {
30-
/// let mut socket = try!(UdpSocket::bind("127.0.0.1:34254"));
30+
/// {
31+
/// let mut socket = try!(UdpSocket::bind("127.0.0.1:34254"));
3132
///
32-
/// let mut buf = [0; 10];
33-
/// let (amt, src) = try!(socket.recv_from(&mut buf));
33+
/// // read from the socket
34+
/// let mut buf = [0; 10];
35+
/// let (amt, src) = try!(socket.recv_from(&mut buf));
3436
///
35-
/// // Send a reply to the socket we received data from
36-
/// let buf = &mut buf[..amt];
37-
/// buf.reverse();
38-
/// try!(socket.send_to(buf, &src));
39-
///
40-
/// drop(socket); // close the socket
41-
/// # Ok(())
37+
/// // send a reply to the socket we received data from
38+
/// let buf = &mut buf[..amt];
39+
/// buf.reverse();
40+
/// try!(socket.send_to(buf, &src));
41+
/// # Ok(())
42+
/// } // the socket is closed here
4243
/// # }
4344
/// ```
4445
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)