From 0eb7303c7062792049c0ec4ff2c42565db6d60ff Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 17 Jul 2015 14:00:03 +0200 Subject: [PATCH 1/6] Add E0403 error explanation --- src/librustc_resolve/diagnostics.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index a0d06e5e1244a..2a5a31dcd194e 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -274,6 +274,21 @@ on this topic: http://doc.rust-lang.org/reference.html#use-declarations "## +E0403: r##" +Some type parameters have the same name. Example of erroneous code: + +``` +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: + +``` +fn foo(s: T, u: Y) {} +``` +"## + } register_diagnostics! { @@ -284,7 +299,6 @@ register_diagnostics! { E0258, E0401, // can't use type parameters from outer function E0402, // cannot use an outer type parameter in this context - E0403, // the name `{}` is already used E0404, // is not a trait E0405, // use of undeclared trait name E0406, // undeclared associated type From cd385cbe34d8a9bad2a6d03c1ef50dd04642a379 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 17 Jul 2015 14:14:41 +0200 Subject: [PATCH 2/6] 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 # From bc79f20ccac4ead82fae1464ea0916e78e04616f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 17 Jul 2015 14:55:42 +0200 Subject: [PATCH 3/6] Add E0404 error explanation --- src/librustc_resolve/diagnostics.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 428e084064ebd..d83829150c553 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -290,6 +290,32 @@ fn foo(s: T, u: Y) {} // ok! ``` "##, +E0404: r##" +You tried to implement a non-trait object on an object. Example of erroneous +code: + +``` +struct Foo; +struct Bar; + +impl Foo for Bar {} // error: `Foo` is not a trait +``` + +Please verify you didn't mispelled the trait's name or used the wrong object. +Example: + +``` +trait Foo { + // some functions +} +struct Bar; + +impl Foo for Bar { // ok! + // functions implementation +} +``` +"##, + E0405: r##" You tried to implement an undefined trait on an object. Example of erroneous code: @@ -330,7 +356,6 @@ register_diagnostics! { E0258, E0401, // can't use type parameters from outer function E0402, // cannot use an outer type parameter in this context - E0404, // is not a trait E0406, // undeclared associated type E0407, // method is not a member of trait E0408, // variable from pattern #1 is not bound in pattern # From 95811546e6dabc1946a155c70a4635b9d76dcb8d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 17 Jul 2015 15:54:44 +0200 Subject: [PATCH 4/6] Add E0407 error explanation --- src/librustc_resolve/diagnostics.rs | 41 ++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index d83829150c553..b135d9c0c4ab1 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -317,8 +317,7 @@ impl Foo for Bar { // ok! "##, E0405: r##" -You tried to implement an undefined trait on an object. Example of -erroneous code: +A non-trait was implemented. Example of erroneous code: ``` struct Foo; @@ -344,7 +343,42 @@ impl SomeTrait for Foo { // ok! // implements functions } ``` -"## +"##, + +E0407: r##" +A definition of a method not in the implemented trait was given. Example of +erroneous code: + +``` +trait Foo { + fn a(); +} + +struct Bar; + +impl Foo for Bar { + fn a() {} + fn b() {} // error: method `b` is not a member of trait `Foo` +} +``` + +Please verify you didn't mispelled the method name and you used the good +trait. Example: + +``` +trait Foo { + fn a(); + fn b(); +} + +struct Bar; + +impl Foo for Bar { + fn a() {} + fn b() {} // ok! +} +``` +"##, } @@ -357,7 +391,6 @@ register_diagnostics! { E0401, // can't use type parameters from outer function E0402, // cannot use an outer type parameter in this context E0406, // undeclared associated type - E0407, // method is not a member of trait E0408, // variable from pattern #1 is not bound in pattern # E0409, // variable is bound with different mode in pattern # than in // pattern #1 From c13295bbc3c887581828583ad8c09be8a21227c8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 17 Jul 2015 16:09:25 +0200 Subject: [PATCH 5/6] Add E0428 error explanation --- src/librustc_resolve/diagnostics.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index b135d9c0c4ab1..96bc3576a94fa 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -380,6 +380,24 @@ impl Foo for Bar { ``` "##, +E0428: r##" +A type or module has been defined more than once. Example of erroneous +code: + +``` +struct Bar; +struct Bar; // error: duplicate definition of value `Bar` +``` + +Please verify you didn't mispelled the type/module's name or remove the +duplicated one. Example: + +``` +struct Bar; +struct Bar2; // ok! +``` +"##, + } register_diagnostics! { @@ -415,7 +433,6 @@ register_diagnostics! { E0425, // unresolved name E0426, // use of undeclared label E0427, // cannot use `ref` binding mode with ... - E0428, // duplicate definition of ... E0429, // `self` imports are only allowed within a { } list E0430, // `self` import can only appear once in the list E0431, // `self` import can only appear in an import list with a non-empty From 2e919b4c5107a584ffcf58e4b39a001275845fec Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 17 Jul 2015 17:21:58 +0200 Subject: [PATCH 6/6] Add E0433 error explanation --- src/librustc_resolve/diagnostics.rs | 54 ++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 96bc3576a94fa..21a950060947b 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -272,7 +272,7 @@ See the 'Use Declarations' section of the reference for more information on this topic: http://doc.rust-lang.org/reference.html#use-declarations -"## +"##, E0403: r##" Some type parameters have the same name. Example of erroneous code: @@ -282,7 +282,7 @@ fn foo(s: T, u: T) {} // error: the name `T` is already used for a type // parameter in this type parameter list ``` -Please verify that none of the type params are misspelled, and rename any +Please verify that none of the type parameterss are misspelled, and rename any clashing parameters. Example: ``` @@ -291,8 +291,8 @@ fn foo(s: T, u: Y) {} // ok! "##, E0404: r##" -You tried to implement a non-trait object on an object. Example of erroneous -code: +You tried to implement something which was not a trait on an object. Example of +erroneous code: ``` struct Foo; @@ -301,8 +301,8 @@ struct Bar; impl Foo for Bar {} // error: `Foo` is not a trait ``` -Please verify you didn't mispelled the trait's name or used the wrong object. -Example: +Please verify that you didn't misspell the trait's name or otherwise use the +wrong identifier. Example: ``` trait Foo { @@ -317,7 +317,7 @@ impl Foo for Bar { // ok! "##, E0405: r##" -A non-trait was implemented. Example of erroneous code: +An unknown trait was implemented. Example of erroneous code: ``` struct Foo; @@ -346,8 +346,8 @@ impl SomeTrait for Foo { // ok! "##, E0407: r##" -A definition of a method not in the implemented trait was given. Example of -erroneous code: +A definition of a method not in the implemented trait was given in a trait +implementation. Example of erroneous code: ``` trait Foo { @@ -362,8 +362,8 @@ impl Foo for Bar { } ``` -Please verify you didn't mispelled the method name and you used the good -trait. Example: +Please verify you didn't misspell the method name and you used the correct +trait. First example: ``` trait Foo { @@ -378,6 +378,24 @@ impl Foo for Bar { fn b() {} // ok! } ``` + +Second example: + +``` +trait Foo { + fn a(); +} + +struct Bar; + +impl Foo for Bar { + fn a() {} +} + +impl Bar { + fn b() {} +} +``` "##, E0428: r##" @@ -389,7 +407,7 @@ struct Bar; struct Bar; // error: duplicate definition of value `Bar` ``` -Please verify you didn't mispelled the type/module's name or remove the +Please verify you didn't misspell the type/module's name or remove/rename the duplicated one. Example: ``` @@ -398,6 +416,17 @@ struct Bar2; // ok! ``` "##, +E0433: r##" +Invalid import. Example of erroneous code: + +``` +use something_which_doesnt_exist; +// error: unresolved import `something_which_doesnt_exist` +``` + +Please verify you didn't misspell the import's name. +"##, + } register_diagnostics! { @@ -438,7 +467,6 @@ register_diagnostics! { E0431, // `self` import can only appear in an import list with a non-empty // prefix E0432, // unresolved import - E0433, // failed to resolve E0434, // can't capture dynamic environment in a fn item E0435, // attempt to use a non-constant value in a constant E0437, // type is not a member of trait