about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-06-29 13:59:33 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-06-29 13:59:33 +0530
commit4adcc78e00b4ae6cd37070669bc1f57111338648 (patch)
tree5ed0b54115a6dee763791b6128e0946a344e84cf
parenta973e4cda5191040ca219fb4a4f8041e9b560301 (diff)
parent7f830a874ccea9cf0ebfe88fa4074d5c5e9c53b4 (diff)
downloadrust-4adcc78e00b4ae6cd37070669bc1f57111338648.tar.gz
rust-4adcc78e00b4ae6cd37070669bc1f57111338648.zip
Rollup merge of #26593 - GuillaumeGomez:patch-2, r=Manishearth
Part of #24407.
cc @michaelsproul
-rw-r--r--src/librustc/diagnostics.rs36
-rw-r--r--src/librustc_typeck/diagnostics.rs65
2 files changed, 97 insertions, 4 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 034d3ee1604..4673169a7de 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -360,6 +360,40 @@ integer type:
 http://doc.rust-lang.org/reference.html#ffi-attributes
 "##,
 
+E0109: r##"
+You tried to give a type parameter to a type which doesn't need it. Erroneous
+code example:
+
+```
+type X = u32<i32>; // error: type parameters are not allowed on this type
+```
+
+Please check that you used the correct type and recheck its definition. Perhaps
+it doesn't need the type parameter.
+Example:
+
+```
+type X = u32; // ok!
+```
+"##,
+
+E0110: r##"
+You tried to give a lifetime parameter to a type which doesn't need it.
+Erroneous code example:
+
+```
+type X = u32<'static>; // error: lifetime parameters are not allowed on
+                       //        this type
+```
+
+Please check that you used the correct type and recheck its definition,
+perhaps it doesn't need the lifetime parameter. Example:
+
+```
+type X = u32; // ok!
+```
+"##,
+
 E0133: r##"
 Using unsafe functionality, such as dereferencing raw pointers and calling
 functions via FFI or marked as unsafe, is potentially dangerous and disallowed
@@ -1055,8 +1089,6 @@ register_diagnostics! {
     E0017,
     E0022,
     E0038,
-    E0109,
-    E0110,
     E0134,
     E0135,
     E0136,
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 5a7f3026ee0..d4977c5d394 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -934,6 +934,51 @@ The number of supplied parameters much exactly match the number of defined type
 parameters.
 "##,
 
+E0088: r##"
+You gave too many lifetime parameters. Erroneous code example:
+
+```
+fn f() {}
+
+fn main() {
+    f::<'static>() // error: too many lifetime parameters provided
+}
+```
+
+Please check you give the right number of lifetime parameters. Example:
+
+```
+fn f() {}
+
+fn main() {
+    f() // ok!
+}
+```
+
+It's also important to note that the Rust compiler can generally
+determine the lifetime by itself. Example:
+
+```
+struct Foo {
+    value: String
+}
+
+impl Foo {
+    // it can be written like this
+    fn get_value<'a>(&'a self) -> &'a str { &self.value }
+    // but the compiler works fine with this too:
+    fn without_lifetime(&self) -> &str { &self.value }
+}
+
+fn main() {
+    let f = Foo { value: "hello".to_owned() };
+
+    println!("{}", f.get_value());
+    println!("{}", f.without_lifetime());
+}
+```
+"##,
+
 E0089: r##"
 Not enough type parameters were supplied for a function. For example:
 
@@ -959,6 +1004,24 @@ fn main() {
 ```
 "##,
 
+E0091: r##"
+You gave an unnecessary type parameter in a type alias. Erroneous code
+example:
+
+```
+type Foo<T> = u32; // error: type parameter `T` is unused
+// or:
+type Foo<A,B> = Box<A>; // error: type parameter `B` is unused
+```
+
+Please check you didn't write too many type parameters. Example:
+
+```
+type Foo = u32; // ok!
+type Foo<A> = Box<A>; // ok!
+```
+"##,
+
 E0106: r##"
 This error indicates that a lifetime is missing from a type. If it is an error
 inside a function signature, the problem may be with failing to adhere to the
@@ -1585,9 +1648,7 @@ register_diagnostics! {
     E0077,
     E0085,
     E0086,
-    E0088,
     E0090,
-    E0091,
     E0092,
     E0093,
     E0094,