From 222e127b2f3bb688d6b44e851acf7b6defc038d4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 18 Jun 2015 16:33:52 +0200 Subject: [PATCH 1/2] Add E0036 error explanation --- src/librustc_typeck/diagnostics.rs | 48 +++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index d89174295a892..30853db7a087d 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 @@ -1322,7 +1369,6 @@ For more information see the [opt-in builtin traits RFC](https://github.com/rust register_diagnostics! { E0034, // multiple applicable methods in scope E0035, // does not take type parameters - E0036, // incorrect number of type parameters given for this method E0044, // foreign items may not have type parameters E0045, // variadic function must have C calling convention E0068, From 38950ae326891fa9c41e01cbb25d38c401ae41eb Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 19 Jun 2015 12:43:41 +0200 Subject: [PATCH 2/2] Good time concordance --- src/librustc_typeck/diagnostics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 30853db7a087d..03b43848838b0 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -212,8 +212,8 @@ 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: +This error occurs when you pass too many or not enough type parameters to +a method. Example: ``` struct Test;