-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add error explaination for E0182, E0230 and E0399 #37244
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@@ -1915,6 +1915,47 @@ More details can be found in [RFC 438]. | |||
[RFC 438]: https://github.com/rust-lang/rfcs/pull/438 | |||
"##, | |||
|
|||
E0182: r##" | |||
You bound an associated type in an expression path which is not | |||
allowed. Erroneous code example: |
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.
"Erroneous code example" sentence needs to be on its own line.
fn bar() -> isize { 42 } | ||
} | ||
|
||
pub fn main() { |
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.
It's better to avoid putting the main function in the examples.
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.
Are you thinking it would be better to just have that line floating after the trait impl?
trait Foo {
type A;
fn bar() -> isize;
}
impl Foo for isize {
type A = usize;
fn bar() -> isize { 42 }
}
// error: unexpected binding of associated item in expression path
let x: isize = Foo::<A=usize>::bar();
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.
Yes. The point is to avoid any unneeded "noise". Everyone knows that code needs to go inside a function and it's not what we're trying to do in here. In the generated output, everything (or almost) is put inside a main function so don't worry about it.
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.
You didn't fix this one.
@@ -2752,6 +2793,28 @@ fn main() { | |||
``` | |||
"##, | |||
|
|||
E0230: r##" | |||
The trait has more type parameters specified than appear in it's definition. |
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.
"its"
@@ -2752,6 +2793,28 @@ fn main() { | |||
``` | |||
"##, | |||
|
|||
E0230: r##" | |||
The trait has more type parameters specified than appear in it's definition. | |||
Erroneous example code: |
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.
Missing empty line before this one.
{} | ||
``` | ||
|
||
Include the correct number of type params and compilation should proceed: |
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.
"params" -> "parameters"
"compilation" -> "the compilation" (I find it better this way but totally open to debate)
@@ -3567,6 +3630,42 @@ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok! | |||
``` | |||
"##, | |||
|
|||
E0399: r##" | |||
You implemented a trait, overriding one or more of it's associated types but did |
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.
"its"
@@ -3567,6 +3630,42 @@ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok! | |||
``` | |||
"##, | |||
|
|||
E0399: r##" | |||
You implemented a trait, overriding one or more of it's associated types but did | |||
not reimplement it's default methods. Example of erroneous code: |
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.
"its"
} | ||
``` | ||
|
||
Add an implementation for the default methods: |
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.
The explanation isn't really explaining anything in here. :-/
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.
Maybe "To fix this, add an implementation for each default method from the trait:"?
} | ||
``` | ||
|
||
To give a concrete type when using the Universal Function Call Syntax, |
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.
I wonder if there are enough details or not... Hard to say from my point of view... :-/
What do you think of this @steveklabnik ?
Thanks for your work! Just a few typos/nits/improvements and it should be good. :) |
@GuillaumeGomez Just pushed up another commit with the fixes |
All good, thanks again! @bors: r+ rollup |
📌 Commit 94c1220 has been approved by |
@bors: r- |
fn bar() -> isize { 42 } | ||
} | ||
|
||
pub fn main() { |
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.
You didn't fix this one.
@@ -3567,6 +3632,42 @@ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok! | |||
``` | |||
"##, | |||
|
|||
E0399: r##" | |||
You implemented a trait, overriding one or more of its associated types but did | |||
not reimplement its default methods. Example of erroneous code: |
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.
"Example of erroneous code example" should be on its own line.
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.
D'oh, good catch.
Sorry, missed remaining things... Also, once done, can you squash the extra commits please (just keep the 3 first ones). If you don't know how to do it, take a look here. |
94c1220
to
9365586
Compare
@GuillaumeGomez No problem, I must have missed that. I fixed up the original 3 commits to include the fixes. |
Ok, now it's good! Thanks again. :) @bors: r+ rollup |
📌 Commit 9365586 has been approved by |
…r=GuillaumeGomez Add error explaination for E0182, E0230 and E0399 This PR adds some error descriptions requested in issue rust-lang#32777. r? @GuillaumeGomez Specifically this adds descriptions for E0182 - unexpected binding of associated item in expression path E0230 - missing type parameter from on_unimplemented description E0399 - overriding a trait type without re-implementing default methods
This PR adds some error descriptions requested in issue #32777.
r? @GuillaumeGomez
Specifically this adds descriptions for
E0182 - unexpected binding of associated item in expression path
E0230 - missing type parameter from on_unimplemented description
E0399 - overriding a trait type without re-implementing default methods