From cd385cbe34d8a9bad2a6d03c1ef50dd04642a379 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 17 Jul 2015 14:14:41 +0200 Subject: [PATCH] Add E0405 error explanation --- src/librustc_resolve/diagnostics.rs | 36 ++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 2a5a31dcd194e..428e084064ebd 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -282,10 +282,41 @@ fn foo(s: T, u: T) {} // error: the name `T` is already used for a type // parameter in this type parameter list ``` -Please verify you didn't mispell the type parameters. Example: +Please verify that none of the type params are misspelled, and rename any +clashing parameters. Example: ``` -fn foo(s: T, u: Y) {} +fn foo(s: T, u: Y) {} // ok! +``` +"##, + +E0405: r##" +You tried to implement an undefined trait on an object. Example of +erroneous code: + +``` +struct Foo; + +impl SomeTrait for Foo {} // error: use of undeclared trait name `SomeTrait` +``` + +Please verify that the name of the trait wasn't misspelled and ensure that it +was imported. Example: + +``` +// solution 1: +use some_file::SomeTrait; + +// solution 2: +trait SomeTrait { + // some functions +} + +struct Foo; + +impl SomeTrait for Foo { // ok! + // implements functions +} ``` "## @@ -300,7 +331,6 @@ register_diagnostics! { E0401, // can't use type parameters from outer function E0402, // cannot use an outer type parameter in this context E0404, // is not a trait - E0405, // use of undeclared trait name E0406, // undeclared associated type E0407, // method is not a member of trait E0408, // variable from pattern #1 is not bound in pattern #