Skip to content

Commit 26f0cd5

Browse files
committed
Auto merge of #26844 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #26599, #26761, #26807, #26809, #26825, #26827, #26828, #26832, #26834, #26835 - Failed merges: #26796
2 parents 6d71ce5 + 04a85c5 commit 26f0cd5

File tree

9 files changed

+377
-33
lines changed

9 files changed

+377
-33
lines changed

CONTRIBUTING.md

+19
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ feature. We use the 'fork and pull' model described there.
8383

8484
Please make pull requests against the `master` branch.
8585

86+
Compiling all of `make check` can take a while. When testing your pull request,
87+
consider using one of the more specialized `make` targets to cut down on the
88+
amount of time you have to wait. You need to have built the compiler at least
89+
once before running these will work, but that’s only one full build rather than
90+
one each time.
91+
92+
$ make -j8 rustc-stage1 && make check-stage1
93+
94+
is one such example, which builds just `rustc`, and then runs the tests. If
95+
you’re adding something to the standard library, try
96+
97+
$ make -j8 check-stage1-std NO_REBUILD=1
98+
99+
This will not rebuild the compiler, but will run the tests.
100+
86101
All pull requests are reviewed by another person. We have a bot,
87102
@rust-highfive, that will automatically assign a random person to review your
88103
request.
@@ -108,6 +123,10 @@ will run all the tests on every platform we support. If it all works out,
108123

109124
[merge-queue]: http://buildbot.rust-lang.org/homu/queue/rust
110125

126+
Speaking of tests, Rust has a comprehensive test suite. More information about
127+
it can be found
128+
[here](https://github.com/rust-lang/rust-wiki-backup/blob/master/Note-testsuite.md).
129+
111130
## Writing Documentation
112131

113132
Documentation improvements are very welcome. The source of `doc.rust-lang.org`

src/doc/reference.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -2515,9 +2515,8 @@ Here are some examples:
25152515
#### Moved and copied types
25162516

25172517
When a [local variable](#variables) is used as an
2518-
[rvalue](#lvalues,-rvalues-and-temporaries) the variable will either be moved
2519-
or copied, depending on its type. All values whose type implements `Copy` are
2520-
copied, all others are moved.
2518+
[rvalue](#lvalues,-rvalues-and-temporaries), the variable will be copied
2519+
if its type implements `Copy`. All others are moved.
25212520

25222521
### Literal expressions
25232522

@@ -2882,7 +2881,6 @@ operand.
28822881
```
28832882
# let mut x = 0;
28842883
# let y = 0;
2885-
28862884
x = y;
28872885
```
28882886

src/doc/trpl/ffi.md

+4-13
Original file line numberDiff line numberDiff line change
@@ -533,19 +533,10 @@ attribute turns off Rust's name mangling, so that it is easier to link to.
533533

534534
# FFI and panics
535535

536-
It’s important to be mindful of `panic!`s when working with FFI. This code,
537-
when called from C, will `abort`:
538-
539-
```rust
540-
#[no_mangle]
541-
pub extern fn oh_no() -> ! {
542-
panic!("Oops!");
543-
}
544-
# fn main() {}
545-
```
546-
547-
If you’re writing code that may panic, you should run it in another thread,
548-
so that the panic doesn’t bubble up to C:
536+
It’s important to be mindful of `panic!`s when working with FFI. A `panic!`
537+
across an FFI boundary is undefined behavior. If you’re writing code that may
538+
panic, you should run it in another thread, so that the panic doesn’t bubble up
539+
to C:
549540

550541
```rust
551542
use std::thread;

src/doc/trpl/patterns.md

+32
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,38 @@ This ‘destructuring’ behavior works on any compound data type, like
282282
[tuples]: primitive-types.html#tuples
283283
[enums]: enums.html
284284

285+
# Ignoring bindings
286+
287+
You can use `_` in a pattern to disregard the value. For example, here’s a
288+
`match` against a `Result<T, E>`:
289+
290+
```rust
291+
# let some_value: Result<i32, &'static str> = Err("There was an error");
292+
match some_value {
293+
Ok(value) => println!("got a value: {}", value),
294+
Err(_) => println!("an error occurred"),
295+
}
296+
```
297+
298+
In the first arm, we bind the value inside the `Ok` variant to `value`. But
299+
in the `Err` arm, we use `_` to disregard the specific error, and just print
300+
a general error message.
301+
302+
`_` is valid in any pattern that creates a binding. This can be useful to
303+
ignore parts of a larger structure:
304+
305+
```rust
306+
fn coordinate() -> (i32, i32, i32) {
307+
// generate and return some sort of triple tuple
308+
# (1, 2, 3)
309+
}
310+
311+
let (x, _, z) = coordinate();
312+
```
313+
314+
Here, we bind the first and last element of the tuple to `x` and `z`, but
315+
ignore the middle element.
316+
285317
# Mix and Match
286318

287319
Whew! That’s a lot of different ways to match things, and they can all be

0 commit comments

Comments
 (0)