]> git.lizzy.rs Git - rust.git/commitdiff
Add E0036 error explanation
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 19 Jun 2015 11:54:57 +0000 (13:54 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 19 Jun 2015 11:54:57 +0000 (13:54 +0200)
src/librustc_typeck/diagnostics.rs

index d89174295a8927db8c9f8db4f416a59863b9145d..5b981ed141d107e2a47c964a558e7e05863e8384 100644 (file)
@@ -211,6 +211,53 @@ struct Dog {
 http://doc.rust-lang.org/reference.html#trait-objects
 "##,
 
+E0036: r##"
+This error occurred when you pass too many or not enough type parameters to a
+method. Example:
+
+```
+struct Test;
+
+impl Test {
+    fn method<T>(&self, v: &[T]) -> usize {
+        v.len()
+    }
+}
+
+fn main() {
+    let x = Test;
+    let v = &[0i32];
+
+    x.method::<i32, i32>(v); // error: only one type parameter is expected!
+}
+```
+
+To fix it, just specify a correct number of type parameters:
+
+```
+struct Test;
+
+impl Test {
+    fn method<T>(&self, v: &[T]) -> usize {
+        v.len()
+    }
+}
+
+fn main() {
+    let x = Test;
+    let v = &[0i32];
+
+    x.method::<i32>(v); // OK, we're good!
+}
+```
+
+Please note on the last example that we could have called `method` like this:
+
+```
+x.method(v);
+```
+"##,
+
 E0040: r##"
 It is not allowed to manually call destructors in Rust. It is also not
 necessary to do this since `drop` is called automatically whenever a value goes