Skip to content

Commit e38210b

Browse files
committed
Auto merge of #28913 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #28621, #28872, #28893, #28904, #28905, #28908, #28910 - Failed merges: #28906
2 parents 64c4b51 + 1625c13 commit e38210b

File tree

7 files changed

+65
-6
lines changed

7 files changed

+65
-6
lines changed

src/doc/grammar.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ symbol : "::" | "->"
258258
| ',' | ';' ;
259259
```
260260

261-
Symbols are a general class of printable [token](#tokens) that play structural
261+
Symbols are a general class of printable [tokens](#tokens) that play structural
262262
roles in a variety of grammar productions. They are catalogued here for
263263
completeness as the set of remaining miscellaneous printable tokens that do not
264264
otherwise appear as [unary operators](#unary-operator-expressions), [binary

src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ The two values of the boolean type are written `true` and `false`.
418418

419419
### Symbols
420420

421-
Symbols are a general class of printable [token](#tokens) that play structural
421+
Symbols are a general class of printable [tokens](#tokens) that play structural
422422
roles in a variety of grammar productions. They are catalogued here for
423423
completeness as the set of remaining miscellaneous printable tokens that do not
424424
otherwise appear as [unary operators](#unary-operator-expressions), [binary

src/doc/trpl/patterns.md

+25
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,31 @@ match x {
2323

2424
This prints `one`.
2525

26+
There’s one pitfall with patterns: like anything that introduces a new binding,
27+
they introduce shadowing. For example:
28+
29+
```rust
30+
let x = 'x';
31+
let c = 'c';
32+
33+
match c {
34+
x => println!("x: {} c: {}", x, c),
35+
}
36+
37+
println!("x: {}", x)
38+
```
39+
40+
This prints:
41+
42+
```text
43+
x: c c: c
44+
x: x
45+
```
46+
47+
In other words, `x =>` matches the pattern and introduces a new binding named
48+
`x` that’s in scope for the match arm. Because we already have a binding named
49+
`x`, this new `x` shadows it.
50+
2651
# Multiple patterns
2752

2853
You can match multiple patterns with `|`:

src/doc/trpl/traits.md

+29
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,32 @@ If we forget to implement `Foo`, Rust will tell us:
492492
```text
493493
error: the trait `main::Foo` is not implemented for the type `main::Baz` [E0277]
494494
```
495+
496+
# Deriving
497+
498+
Implementing traits like `Debug` and `Default` over and over again can become
499+
quite tedious. For that reason, Rust provides an [attribute][attributes] that
500+
allows you to let Rust automatically implement traits for you:
501+
502+
```rust
503+
#[derive(Debug)]
504+
struct Foo;
505+
506+
fn main() {
507+
println!("{:?}", Foo);
508+
}
509+
```
510+
511+
[attributes]: attributes.html
512+
513+
However, deriving is limited to a certain set of traits:
514+
515+
- [`Clone`](../core/clone/trait.Clone.html)
516+
- [`Copy`](../core/marker/trait.Copy.html)
517+
- [`Debug`](../core/fmt/trait.Debug.html)
518+
- [`Default`](../core/default/trait.Default.html)
519+
- [`Eq`](../core/cmp/trait.Eq.html)
520+
- [`Hash`](../core/hash/trait.Hash.html)
521+
- [`Ord`](../core/cmp/trait.Ord.html)
522+
- [`PartialEq`](../core/cmp/trait.PartialEq.html)
523+
- [`PartialOrd`](../core/cmp/trait.PartialOrd.html)

src/libcore/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ pub trait Iterator {
935935

936936
/// Creates an iterator that clones the elements it yields.
937937
///
938-
/// This is useful for converting an Iterator<&T> to an Iterator<T>,
938+
/// This is useful for converting an `Iterator<&T>` to an`Iterator<T>`,
939939
/// so it's a more convenient form of `map(|&x| x)`.
940940
///
941941
/// # Examples

src/librustc_driver/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,12 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
285285
-> Compilation {
286286
match matches.opt_str("explain") {
287287
Some(ref code) => {
288-
match descriptions.find_description(&code[..]) {
288+
let normalised = if !code.starts_with("E") {
289+
format!("E{0:0>4}", code)
290+
} else {
291+
code.to_string()
292+
};
293+
match descriptions.find_description(&normalised) {
289294
Some(ref description) => {
290295
// Slice off the leading newline and print.
291296
print!("{}", &description[1..]);

src/librustc_typeck/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1308,8 +1308,8 @@ extern "rust-intrinsic" {
13081308
"##,
13091309

13101310
E0101: r##"
1311-
You hit this error because the compiler the compiler lacks information
1312-
to determine a type for this expression. Erroneous code example:
1311+
You hit this error because the compiler lacks the information to
1312+
determine a type for this expression. Erroneous code example:
13131313
13141314
```
13151315
fn main() {

0 commit comments

Comments
 (0)