From 98205afe0b09b22e9d88968ed61095b15fcfb1e3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 19 Jun 2015 13:54:57 +0200 Subject: [PATCH] Add E0036 error explanation --- src/librustc_typeck/diagnostics.rs | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index d89174295a89..5b981ed141d1 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -211,6 +211,53 @@ Reference: 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(&self, v: &[T]) -> usize { + v.len() + } +} + +fn main() { + let x = Test; + let v = &[0i32]; + + x.method::(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(&self, v: &[T]) -> usize { + v.len() + } +} + +fn main() { + let x = Test; + let v = &[0i32]; + + x.method::(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