From 7d9e605b93eb3ac359b3470dce829ed8432012d1 Mon Sep 17 00:00:00 2001
From: Ricardo Martins <ricardo@scarybox.net>
Date: Sun, 10 May 2015 10:43:30 +0100
Subject: [PATCH 1/7] Add error explanation for E0317.

---
 src/librustc_resolve/diagnostics.rs | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index a896bd311698c..3e7ee714ea9f9 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -10,6 +10,24 @@
 
 #![allow(non_snake_case)]
 
+// Error messages for EXXXX errors.
+// Each message should start and end with a new line, and be wrapped to 80 characters.
+// In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
+register_long_diagnostics! {
+
+E0317: r##"
+User-defined types or type parameters cannot shadow the primitive types.
+This error indicates you tried to define a type, struct or enum with the same
+name as an existing primitive type, and is therefore invalid.
+
+See the Types section of the reference for more information about the primitive
+types:
+
+http://doc.rust-lang.org/nightly/reference.html#types
+"##
+
+}
+
 register_diagnostics! {
     E0154,
     E0157,
@@ -24,7 +42,6 @@ register_diagnostics! {
     E0258, // import conflicts with existing submodule
     E0259, // an extern crate has already been imported into this module
     E0260, // name conflicts with an external crate that has been imported into this module
-    E0317, // user-defined types or type parameters cannot shadow the primitive types
     E0364, // item is private
     E0365  // item is private
 }

From c0412bcad69d95e217211bf6be925802004e4b17 Mon Sep 17 00:00:00 2001
From: Ricardo Martins <ricardo@scarybox.net>
Date: Sun, 10 May 2015 12:16:33 +0100
Subject: [PATCH 2/7] Fix documentation URL in diagnostic message.

---
 src/librustc_resolve/diagnostics.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 3e7ee714ea9f9..dd867d676ed2f 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -23,7 +23,7 @@ name as an existing primitive type, and is therefore invalid.
 See the Types section of the reference for more information about the primitive
 types:
 
-http://doc.rust-lang.org/nightly/reference.html#types
+http://doc.rust-lang.org/reference.html#types
 "##
 
 }

From f3a3684614c0baf01e2d22e662b67e6a1408b718 Mon Sep 17 00:00:00 2001
From: Ricardo Martins <ricardo@scarybox.net>
Date: Sun, 10 May 2015 11:40:43 +0100
Subject: [PATCH 3/7] Add error explanation for E0154.

---
 src/librustc_resolve/diagnostics.rs | 33 ++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index dd867d676ed2f..4b754913bd9fb 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -15,6 +15,38 @@
 // In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
 register_long_diagnostics! {
 
+E0154: r##"
+Imports (`use` statements) are not allowed after non-item statements, such as
+variable declarations and expression statements.
+
+Wrong example:
+```
+fn f() {
+    // Variable declaration before import
+    let x = 0;
+    use std::io::Read;
+    ...
+}
+```
+
+The solution is to declare the imports at the top of the block, function, or
+file.
+
+Here is the previous example again, with the correct order:
+```
+fn f() {
+    use std::io::Read;
+    let x = 0;
+    ...
+}
+```
+
+See the Declaration Statements section of the reference for more information
+about what constitutes an Item declaration and what does not:
+
+http://doc.rust-lang.org/reference.html#statements
+"##,
+
 E0317: r##"
 User-defined types or type parameters cannot shadow the primitive types.
 This error indicates you tried to define a type, struct or enum with the same
@@ -29,7 +61,6 @@ http://doc.rust-lang.org/reference.html#types
 }
 
 register_diagnostics! {
-    E0154,
     E0157,
     E0153,
     E0251, // a named type or value has already been imported in this module

From e7fa00a3e24f094012f878945bef8a62df1678c1 Mon Sep 17 00:00:00 2001
From: Ricardo Martins <ricardo@scarybox.net>
Date: Sun, 10 May 2015 12:09:41 +0100
Subject: [PATCH 4/7] Add error explanation for E0259.

---
 src/librustc_resolve/diagnostics.rs | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 4b754913bd9fb..47f9b024fd051 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -47,6 +47,26 @@ about what constitutes an Item declaration and what does not:
 http://doc.rust-lang.org/reference.html#statements
 "##,
 
+E0259: r##"
+The name chosen for an external crate conflicts with another external crate that
+has been imported into the current module.
+
+Wrong example:
+```
+extern a;
+extern crate_a as a;
+```
+
+The solution is to choose a different name that doesn't conflict with any
+external crate imported into the current module.
+
+Correct example:
+```
+extern a;
+extern crate_a as other_name;
+```
+"##,
+
 E0317: r##"
 User-defined types or type parameters cannot shadow the primitive types.
 This error indicates you tried to define a type, struct or enum with the same
@@ -71,7 +91,6 @@ register_diagnostics! {
     E0256, // import conflicts with type in this module
     E0257, // inherent implementations are only allowed on types defined in the current module
     E0258, // import conflicts with existing submodule
-    E0259, // an extern crate has already been imported into this module
     E0260, // name conflicts with an external crate that has been imported into this module
     E0364, // item is private
     E0365  // item is private

From 60ec4ab220385be1ad2aef237733d7f38c2196b3 Mon Sep 17 00:00:00 2001
From: Ricardo Martins <ricardo@scarybox.net>
Date: Sun, 10 May 2015 12:26:19 +0100
Subject: [PATCH 5/7] Add error explanation for E0260.

---
 src/librustc_resolve/diagnostics.rs | 35 ++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 47f9b024fd051..5f0b5af9a0532 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -67,6 +67,40 @@ extern crate_a as other_name;
 ```
 "##,
 
+E0260: r##"
+The name for an item declaration conflicts with an external crate's name.
+
+For instance,
+```
+extern abc;
+
+struct abc;
+```
+
+There are two possible solutions:
+
+Solution #1: Rename the item.
+
+```
+extern abc;
+
+struct xyz;
+```
+
+Solution #2: Import the crate with a different name.
+
+```
+extern abc as xyz;
+
+struct abc;
+```
+
+See the Declaration Statements section of the reference for more information
+about what constitutes an Item declaration and what does not:
+
+http://doc.rust-lang.org/reference.html#statements
+"##,
+
 E0317: r##"
 User-defined types or type parameters cannot shadow the primitive types.
 This error indicates you tried to define a type, struct or enum with the same
@@ -91,7 +125,6 @@ register_diagnostics! {
     E0256, // import conflicts with type in this module
     E0257, // inherent implementations are only allowed on types defined in the current module
     E0258, // import conflicts with existing submodule
-    E0260, // name conflicts with an external crate that has been imported into this module
     E0364, // item is private
     E0365  // item is private
 }

From ef030555c67988878e1a68743da25b5107bd2787 Mon Sep 17 00:00:00 2001
From: Ricardo Martins <ricardo@scarybox.net>
Date: Mon, 11 May 2015 09:10:19 +0100
Subject: [PATCH 6/7] Improve wording in error explanation.

---
 src/librustc_resolve/diagnostics.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 5f0b5af9a0532..2ac6ffdea2d65 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -19,7 +19,7 @@ E0154: r##"
 Imports (`use` statements) are not allowed after non-item statements, such as
 variable declarations and expression statements.
 
-Wrong example:
+Here is an example that demonstrates the error:
 ```
 fn f() {
     // Variable declaration before import
@@ -104,7 +104,7 @@ http://doc.rust-lang.org/reference.html#statements
 E0317: r##"
 User-defined types or type parameters cannot shadow the primitive types.
 This error indicates you tried to define a type, struct or enum with the same
-name as an existing primitive type, and is therefore invalid.
+name as an existing primitive type.
 
 See the Types section of the reference for more information about the primitive
 types:

From aa529ef52e54039fcfaa8aa7914be4c581179497 Mon Sep 17 00:00:00 2001
From: Ricardo Martins <ricardo@scarybox.net>
Date: Mon, 11 May 2015 09:10:49 +0100
Subject: [PATCH 7/7] Add missing keyword in `extern crate` declarations.

---
 src/librustc_resolve/diagnostics.rs | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 2ac6ffdea2d65..7e7af8006805d 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -53,8 +53,8 @@ has been imported into the current module.
 
 Wrong example:
 ```
-extern a;
-extern crate_a as a;
+extern crate a;
+extern crate crate_a as a;
 ```
 
 The solution is to choose a different name that doesn't conflict with any
@@ -62,8 +62,8 @@ external crate imported into the current module.
 
 Correct example:
 ```
-extern a;
-extern crate_a as other_name;
+extern crate a;
+extern crate crate_a as other_name;
 ```
 "##,
 
@@ -72,7 +72,7 @@ The name for an item declaration conflicts with an external crate's name.
 
 For instance,
 ```
-extern abc;
+extern crate abc;
 
 struct abc;
 ```
@@ -82,7 +82,7 @@ There are two possible solutions:
 Solution #1: Rename the item.
 
 ```
-extern abc;
+extern crate abc;
 
 struct xyz;
 ```
@@ -90,7 +90,7 @@ struct xyz;
 Solution #2: Import the crate with a different name.
 
 ```
-extern abc as xyz;
+extern crate abc as xyz;
 
 struct abc;
 ```