-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add E0417, E0424, E0425, E0426, E0430, E0431 and E0432 error explanations #27230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d6b9e0b
Add E0417 error explanation
GuillaumeGomez 8a75dcd
Add E0424 error explanation
GuillaumeGomez 0efc7f1
Fix typo and improve explanation
GuillaumeGomez 1f81002
Improve error explanation
GuillaumeGomez 18f4e8c
Add E0430 error explanation
GuillaumeGomez 2537abf
Add E0431 error explanation
GuillaumeGomez 9e1ea5e
Add E0432 error explanation
GuillaumeGomez c8b9e83
Add E0426 error explanation
GuillaumeGomez 40617b6
Add E0425 error explanation
GuillaumeGomez fc65f55
Fix typo
GuillaumeGomez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,6 +397,66 @@ 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 | ||
_ => {} | ||
} | ||
``` | ||
|
||
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; | ||
|
||
match 0 { | ||
FOO => {} // ok! | ||
_ => {} | ||
} | ||
``` | ||
"##, | ||
|
||
E0424: r##" | ||
The `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 check if the method's argument list should have contained self, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
&self, or &mut self (in case you didn't want to create a static method), | ||
and add it if so. Example: | ||
|
||
``` | ||
struct Foo; | ||
|
||
impl Foo { | ||
fn bar(self) {} | ||
|
||
fn foo(self) { | ||
self.bar(); // ok! | ||
} | ||
} | ||
``` | ||
"##, | ||
|
||
E0428: r##" | ||
A type or module has been defined more than once. Example of erroneous | ||
code: | ||
|
@@ -448,16 +508,13 @@ 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 | ||
E0421, // unresolved associated const | ||
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 ... | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: saying "is not possible" may be re-opening a can of worms by implicitly inviting back those who were arguing, back when we first split up the two forms, that the
static
/const
distinction was unnecessary.I would prefer something like: