about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-01-20 16:14:42 +0530
committerManish Goregaokar <manishsmail@gmail.com>2016-01-20 16:18:10 +0530
commita6778a2f360c357679f37f6a3b26cdb902659411 (patch)
treedc54e3d380bf2097e351e59c5e45840e106602cb
parentf8c2d57f4c69ff8972178ee21e99d40a8f777d2c (diff)
Improve E0317 long diagnostics
-rw-r--r--src/librustc_resolve/diagnostics.rs36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 04ab3fe70e9..dc6da1f0ef8 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -207,7 +207,41 @@ https://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.
+name as an existing primitive type:
+
+```
+struct u8 {
+    // ...
+}
+```
+
+To fix this, simply name it something else.
+
+Such an error may also occur if you define a type parameter which shadows a
+primitive type. An example would be something like:
+
+```
+impl<u8> MyTrait for Option<u8> {
+    // ...
+}
+```
+
+In such a case, if you meant for `u8` to be a generic type parameter (i.e. any
+type can be used in its place), use something like `T` instead:
+
+```
+impl<T> MyTrait for Option<T> {
+    // ...
+}
+```
+
+On the other hand, if you wished to refer to the specific type `u8`, remove it
+from the type parameter list:
+
+```
+impl MyTrait for Option<u8> {
+    // ...
+}
 
 See the Types section of the reference for more information about the primitive
 types: