From d6b9e0bed95fb747d40c81f53f8c5015f2df97be Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 23 Jul 2015 12:28:01 +0200 Subject: [PATCH 01/10] Add E0417 error explanation --- src/librustc_resolve/diagnostics.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 5a941c757fc..9edddec946d 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -397,6 +397,33 @@ impl Bar { ``` "##, +E0417: r##" +A static variable was referenced in a pattern. Example of erroneous code: + +``` +static FOO : i32 = 0; + +match 0 { + FOO => {} // error: static variables cannot be referenced in a + // pattern, use a `const` instead + _ => {} +} +``` + +Compiler needs to know the pattern value at compile's time, which is +not possible with a `static` variable. So please verify you didn't +misspell the variable's name or use a `const` instead. Example: + +``` +const FOO : i32 = 0; + +match 0 { + FOO => {} // ok! + _ => {} +} +``` +"##, + E0428: r##" A type or module has been defined more than once. Example of erroneous code: @@ -448,8 +475,6 @@ register_diagnostics! { E0414, // only irrefutable patterns allowed here E0415, // identifier is bound more than once in this parameter list E0416, // identifier is bound more than once in the same pattern - E0417, // static variables cannot be referenced in a pattern, use a - // `const` instead E0418, // is not an enum variant, struct or const E0419, // unresolved enum variant, struct or const E0420, // is not an associated const From 8a75dcdadfe8c3657c5a6f085a984e1c97b48910 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 23 Jul 2015 12:44:59 +0200 Subject: [PATCH 02/10] Add E0424 error explanation --- src/librustc_resolve/diagnostics.rs | 44 ++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 9edddec946d..35b79525dd7 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -424,6 +424,49 @@ match 0 { ``` "##, +E0424: r##" +`self` keyword was used in a static method. Example of erroneous code: + +``` +struct Foo; + +impl Foo { + fn bar(self) {} + + fn foo() { + self.bar(); // error: `self` is not available in a static method. + } +} +``` + +Please verify you didn't forget to add `self` in your method's argument +list if your intention wasn't to create a static method. Example: + +``` +struct Foo; + +impl Foo { + fn bar(self) {} + + fn foo(self) { + self.bar(); // ok! + } +} +``` + +Or please verify you didn't misspell the variable's name: + +``` +struct Foo; + +impl Foo { + fn foo(sel: i32) { + println!("{}", sel); // ok! + } +} +``` +"##, + E0428: r##" A type or module has been defined more than once. Example of erroneous code: @@ -482,7 +525,6 @@ register_diagnostics! { E0422, // does not name a structure E0423, // is a struct variant name, but this expression uses it like a // function name - E0424, // `self` is not available in a static method. E0425, // unresolved name E0426, // use of undeclared label E0427, // cannot use `ref` binding mode with ... From 0efc7f143f7659ca025d555d4f9ca373320e72c4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 23 Jul 2015 16:19:37 +0200 Subject: [PATCH 03/10] Fix typo and improve explanation --- src/librustc_resolve/diagnostics.rs | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 35b79525dd7..8a5f78fc811 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -410,9 +410,10 @@ match 0 { } ``` -Compiler needs to know the pattern value at compile's time, which is -not possible with a `static` variable. So please verify you didn't -misspell the variable's name or use a `const` instead. Example: +The compiler needs to know the value of the pattern at compile time, +which is not possible with a `static` variable. Please verify that the +variable is spelled correctly and if so, try to use a `const` instead. +Example: ``` const FOO : i32 = 0; @@ -425,7 +426,7 @@ match 0 { "##, E0424: r##" -`self` keyword was used in a static method. Example of erroneous code: +The `self` keyword was used in a static method. Example of erroneous code: ``` struct Foo; @@ -439,8 +440,9 @@ impl Foo { } ``` -Please verify you didn't forget to add `self` in your method's argument -list if your intention wasn't to create a static method. Example: +Please check if the method's argument list should have contained self, +&self, or &mut self (in case you didn't want to create a static method), +and add it if so. Example: ``` struct Foo; @@ -453,18 +455,6 @@ impl Foo { } } ``` - -Or please verify you didn't misspell the variable's name: - -``` -struct Foo; - -impl Foo { - fn foo(sel: i32) { - println!("{}", sel); // ok! - } -} -``` "##, E0428: r##" From 1f810027577461d516297a3cce6f42a201f24a6a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 24 Jul 2015 11:02:26 +0200 Subject: [PATCH 04/10] Improve error explanation --- src/librustc_resolve/diagnostics.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 8a5f78fc811..d3ec6e558b9 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -410,10 +410,10 @@ match 0 { } ``` -The compiler needs to know the value of the pattern at compile time, -which is not possible with a `static` variable. Please verify that the -variable is spelled correctly and if so, try to use a `const` instead. -Example: +The compiler needs to know the value of the pattern at compile time; +compile-time patterns can defined via const or enum items. Please verify +that the identifier is spelled correctly, and if so, use a const instead +of static to define it. Example: ``` const FOO : i32 = 0; From 18f4e8ce5eabd77c872b5429b9a0172f0d446c9e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 24 Jul 2015 12:19:36 +0200 Subject: [PATCH 05/10] Add E0430 error explanation --- src/librustc_resolve/diagnostics.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index d3ec6e558b9..8762c82015e 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -475,6 +475,18 @@ struct Bar2; // ok! ``` "##, +E0430: r##" +The `self` import appears more than once in the list. + +``` +use something::{self, self}; // error: `self` import can only appear once in + // the list +``` + +Please verify you didn't misspell the import name or remove the duplicated +`self` import. +"##, + E0433: r##" Invalid import. Example of erroneous code: @@ -519,7 +531,6 @@ register_diagnostics! { E0426, // use of undeclared label E0427, // cannot use `ref` binding mode with ... 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 // prefix E0432, // unresolved import From 2537abf503e1ac44a3b97fab6190ac4dff01a8ff Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 24 Jul 2015 12:24:12 +0200 Subject: [PATCH 06/10] Add E0431 error explanation --- src/librustc_resolve/diagnostics.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 8762c82015e..a737a5ebe65 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -476,7 +476,7 @@ struct Bar2; // ok! "##, E0430: r##" -The `self` import appears more than once in the list. +The `self` import appears more than once in the list. Erroneous code example: ``` use something::{self, self}; // error: `self` import can only appear once in @@ -487,6 +487,18 @@ Please verify you didn't misspell the import name or remove the duplicated `self` import. "##, +E0431: r##" +`self` import was made. Erroneous code example: + +``` +use {self}; // error: `self` import can only appear in an import list with a + // non-empty prefix +``` + +You can't import the current module in itself, please remove this import or +verify you didn't misspell it. +"##, + E0433: r##" Invalid import. Example of erroneous code: @@ -531,8 +543,6 @@ register_diagnostics! { E0426, // use of undeclared label E0427, // cannot use `ref` binding mode with ... E0429, // `self` imports are only allowed within a { } list - E0431, // `self` import can only appear in an import list with a non-empty - // prefix E0432, // unresolved import E0434, // can't capture dynamic environment in a fn item E0435, // attempt to use a non-constant value in a constant From 9e1ea5e5ee6369128e2a3005bb78edc059fa9195 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 24 Jul 2015 12:30:14 +0200 Subject: [PATCH 07/10] Add E0432 error explanation --- src/librustc_resolve/diagnostics.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index a737a5ebe65..5bce8722c94 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -484,7 +484,11 @@ use something::{self, self}; // error: `self` import can only appear once in ``` Please verify you didn't misspell the import name or remove the duplicated -`self` import. +`self` import. Example: + +``` +use something::self; // ok! +``` "##, E0431: r##" @@ -499,6 +503,25 @@ You can't import the current module in itself, please remove this import or verify you didn't misspell it. "##, +E0432: r##" +An import was unresolved. Erroneous code example: + +``` +use something::Foo; // error: unresolved import `something::Foo`. +``` + +Please verify you didn't misspell the import name or the import does exist +in the module from where you tried to import it. Example: + +``` +use something::Foo; // ok! + +mod something { + pub struct Foo; +} +``` +"##, + E0433: r##" Invalid import. Example of erroneous code: @@ -543,7 +566,6 @@ register_diagnostics! { E0426, // use of undeclared label E0427, // cannot use `ref` binding mode with ... E0429, // `self` imports are only allowed within a { } list - E0432, // unresolved import 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 From c8b9e8363a15c0476040869d2e6749018ae4a6b3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 24 Jul 2015 14:44:44 +0200 Subject: [PATCH 08/10] Add E0426 error explanation --- src/librustc_resolve/diagnostics.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 5bce8722c94..6753507b90d 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -457,6 +457,25 @@ impl Foo { ``` "##, +E0426: r##" +An undeclared label was used. Example of erroneous code: + +``` +loop { + break 'a; // error: use of undeclared label `'a` +} +``` + +Please verify you didn't misspell the label name or you did declare +it. Example: + +``` +'a: loop { + break 'a; // ok! +} +``` +"##, + E0428: r##" A type or module has been defined more than once. Example of erroneous code: @@ -563,7 +582,6 @@ register_diagnostics! { E0423, // is a struct variant name, but this expression uses it like a // function name E0425, // unresolved name - E0426, // use of undeclared label E0427, // cannot use `ref` binding mode with ... E0429, // `self` imports are only allowed within a { } list E0434, // can't capture dynamic environment in a fn item From 40617b60cbbf78bb20ba662b192957b58d07dbba Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 24 Jul 2015 14:58:00 +0200 Subject: [PATCH 09/10] Add E0425 error explanation --- src/librustc_resolve/diagnostics.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 6753507b90d..22bfda2ba87 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -457,6 +457,29 @@ impl Foo { ``` "##, +E0425: r##" +An unresolved name was used. Example of erroneous code: + +``` +something_that_doesnt_exist::foo; // error: unresolved name `f::foo` +``` + +Please verify you didn't misspell the name or that you're not using an +invalid object. Example: + +``` +enum something_that_does_exist { + foo +} +// or: +mod something_that_does_exist { + pub static foo : i32 = 0i32; +} + +something_that_does_exist::foo; // ok! +``` +"##, + E0426: r##" An undeclared label was used. Example of erroneous code: @@ -581,7 +604,6 @@ register_diagnostics! { E0422, // does not name a structure E0423, // is a struct variant name, but this expression uses it like a // function name - E0425, // unresolved name E0427, // cannot use `ref` binding mode with ... E0429, // `self` imports are only allowed within a { } list E0434, // can't capture dynamic environment in a fn item From fc65f5551d00b4a83192cc054b6294cf855ba748 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 24 Jul 2015 17:26:41 +0200 Subject: [PATCH 10/10] Fix typo --- src/librustc_resolve/diagnostics.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 22bfda2ba87..b02f5cde36f 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -440,9 +440,9 @@ impl Foo { } ``` -Please check if the method's argument list should have contained self, -&self, or &mut self (in case you didn't want to create a static method), -and add it if so. Example: +Please check if the method's argument list should have contained `self`, +`&self`, or `&mut self` (in case you didn't want to create a static +method), and add it if so. Example: ``` struct Foo; @@ -458,10 +458,18 @@ impl Foo { "##, E0425: r##" -An unresolved name was used. Example of erroneous code: +An unresolved name was used. Example of erroneous codes: ``` -something_that_doesnt_exist::foo; // error: unresolved name `f::foo` +something_that_doesnt_exist::foo; +// error: unresolved name `something_that_doesnt_exist::foo` + +// or: +trait Foo { + fn bar() { + Self; // error: unresolved name `Self` + } +} ``` Please verify you didn't misspell the name or that you're not using an @@ -489,8 +497,7 @@ loop { } ``` -Please verify you didn't misspell the label name or you did declare -it. Example: +Please verify you spelt or declare the label correctly. Example: ``` 'a: loop { @@ -541,8 +548,8 @@ use {self}; // error: `self` import can only appear in an import list with a // non-empty prefix ``` -You can't import the current module in itself, please remove this import or -verify you didn't misspell it. +You cannot import the current module into itself, please remove this import +or verify you didn't misspell it. "##, E0432: r##"