about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-10-08 19:05:54 +0000
committerbors <bors@rust-lang.org>2015-10-08 19:05:54 +0000
commite38210b195a4aaf91f3daa37dfcfd7059bd22ddc (patch)
treef51b82cc8dd65e299acfee19df764623f060271b
parent64c4b51dd6771a0dd61639092ae5b349082b6eb0 (diff)
parent1625c133de832c8350d5e6c9d39510959ffbe5e6 (diff)
downloadrust-e38210b195a4aaf91f3daa37dfcfd7059bd22ddc.tar.gz
rust-e38210b195a4aaf91f3daa37dfcfd7059bd22ddc.zip
Auto merge of #28913 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #28621, #28872, #28893, #28904, #28905, #28908, #28910
- Failed merges: #28906
-rw-r--r--src/doc/grammar.md2
-rw-r--r--src/doc/reference.md2
-rw-r--r--src/doc/trpl/patterns.md25
-rw-r--r--src/doc/trpl/traits.md29
-rw-r--r--src/libcore/iter.rs2
-rw-r--r--src/librustc_driver/lib.rs7
-rw-r--r--src/librustc_typeck/diagnostics.rs4
7 files changed, 65 insertions, 6 deletions
diff --git a/src/doc/grammar.md b/src/doc/grammar.md
index 7bfe8b62e8a..0fd3070d3bd 100644
--- a/src/doc/grammar.md
+++ b/src/doc/grammar.md
@@ -258,7 +258,7 @@ symbol : "::" | "->"
        | ',' | ';' ;
 ```
 
-Symbols are a general class of printable [token](#tokens) that play structural
+Symbols are a general class of printable [tokens](#tokens) that play structural
 roles in a variety of grammar productions. They are catalogued here for
 completeness as the set of remaining miscellaneous printable tokens that do not
 otherwise appear as [unary operators](#unary-operator-expressions), [binary
diff --git a/src/doc/reference.md b/src/doc/reference.md
index a3fda91a6cf..c85b7973ee7 100644
--- a/src/doc/reference.md
+++ b/src/doc/reference.md
@@ -418,7 +418,7 @@ The two values of the boolean type are written `true` and `false`.
 
 ### Symbols
 
-Symbols are a general class of printable [token](#tokens) that play structural
+Symbols are a general class of printable [tokens](#tokens) that play structural
 roles in a variety of grammar productions. They are catalogued here for
 completeness as the set of remaining miscellaneous printable tokens that do not
 otherwise appear as [unary operators](#unary-operator-expressions), [binary
diff --git a/src/doc/trpl/patterns.md b/src/doc/trpl/patterns.md
index 3d22066c725..8f4a7a43955 100644
--- a/src/doc/trpl/patterns.md
+++ b/src/doc/trpl/patterns.md
@@ -23,6 +23,31 @@ match x {
 
 This prints `one`.
 
+There’s one pitfall with patterns: like anything that introduces a new binding,
+they introduce shadowing. For example:
+
+```rust
+let x = 'x';
+let c = 'c';
+
+match c {
+    x => println!("x: {} c: {}", x, c),
+}
+
+println!("x: {}", x)
+```
+
+This prints:
+
+```text
+x: c c: c
+x: x
+```
+
+In other words, `x =>` matches the pattern and introduces a new binding named
+`x` that’s in scope for the match arm. Because we already have a binding named
+`x`, this new `x` shadows it.
+
 # Multiple patterns
 
 You can match multiple patterns with `|`:
diff --git a/src/doc/trpl/traits.md b/src/doc/trpl/traits.md
index 0870a6ef341..27debf86e39 100644
--- a/src/doc/trpl/traits.md
+++ b/src/doc/trpl/traits.md
@@ -492,3 +492,32 @@ If we forget to implement `Foo`, Rust will tell us:
 ```text
 error: the trait `main::Foo` is not implemented for the type `main::Baz` [E0277]
 ```
+
+# Deriving
+
+Implementing traits like `Debug` and `Default` over and over again can become
+quite tedious. For that reason, Rust provides an [attribute][attributes] that
+allows you to let Rust automatically implement traits for you:
+
+```rust
+#[derive(Debug)]
+struct Foo;
+
+fn main() {
+    println!("{:?}", Foo);
+}
+```
+
+[attributes]: attributes.html
+
+However, deriving is limited to a certain set of traits:
+
+- [`Clone`](../core/clone/trait.Clone.html)
+- [`Copy`](../core/marker/trait.Copy.html)
+- [`Debug`](../core/fmt/trait.Debug.html)
+- [`Default`](../core/default/trait.Default.html)
+- [`Eq`](../core/cmp/trait.Eq.html)
+- [`Hash`](../core/hash/trait.Hash.html)
+- [`Ord`](../core/cmp/trait.Ord.html)
+- [`PartialEq`](../core/cmp/trait.PartialEq.html)
+- [`PartialOrd`](../core/cmp/trait.PartialOrd.html)
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 00c7773fd8b..3554325d0db 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -935,7 +935,7 @@ pub trait Iterator {
 
     /// Creates an iterator that clones the elements it yields.
     ///
-    /// This is useful for converting an Iterator<&T> to an Iterator<T>,
+    /// This is useful for converting an `Iterator<&T>` to an`Iterator<T>`,
     /// so it's a more convenient form of `map(|&x| x)`.
     ///
     /// # Examples
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index d5644d49e1e..e4f033efb58 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -285,7 +285,12 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
                       -> Compilation {
         match matches.opt_str("explain") {
             Some(ref code) => {
-                match descriptions.find_description(&code[..]) {
+                let normalised = if !code.starts_with("E") {
+                    format!("E{0:0>4}", code)
+                } else {
+                    code.to_string()
+                };
+                match descriptions.find_description(&normalised) {
                     Some(ref description) => {
                         // Slice off the leading newline and print.
                         print!("{}", &description[1..]);
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 8408e9c0c70..4746819f6a9 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -1308,8 +1308,8 @@ extern "rust-intrinsic" {
 "##,
 
 E0101: r##"
-You hit this error because the compiler the compiler lacks information
-to determine a type for this expression. Erroneous code example:
+You hit this error because the compiler lacks the information to
+determine a type for this expression. Erroneous code example:
 
 ```
 fn main() {