-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Improve the long explanation of E0207. #33692
Conversation
fn get(&self) -> usize; | ||
struct Foo; | ||
|
||
impl<T:Default> Foo { |
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: space after colon
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.
Addressed, thanks.
What generally bugs me in here is that it doesn't follow the waiting for getting merged RFC about error explanations. |
@GuillaumeGomez can you be more specific about how this explanation doesn't match? I just added a little bit more description to my first example, but other than that I'm not sure I understand what you would like to see changed. |
Your changes are great, the point is not here. But currently, we're trying to uniformize the error explanations "template" by forcing people to follow the RFC I linked. This error explanation doesn't, and since you updated it, could you make fit to it please? 😺 |
The problem is I've read the RFC multiple times and I don't understand how my explanation fails to adhere to the template. The only thing I can see is that my explanation does not literally contain the phrase "Example of erroneous code:", but I don't see how inserting this exact phrase improves the explanation. Here's an attempt at trying to match my explanation to the template: Error descriptionAny type parameter or lifetime parameter of an
Minimal example 1For example, when implementing a method for a struct
Error explanation 1The problem is that the parameter How to fix the problem
Minimal example 2As another example, suppose we have a
Error explanation 2This fails to compile because How to fix the problem, option 1One way to work around this is to introduce a phantom type parameter into
How to fix the problem, option 2Another way is to do away with the associated type in
Additional informationFor more information, please see RFC 447. Could you explain specifically what changes you think need to be made? |
Having the error message in a comment would be nice. |
@arielb1 Thanks, added. |
Sure, you just forgot a few little things. For example, before the very first you need to add "Example of erroneous code:". In erroneous codes, you need to add the compiler error in a comment. In other code examples, you need to add little comments to explain what you did. |
I've added Markdown headers so that the explanation is structured like this:
I think the headers nicely organize this explanation. You can see the HTML version here Without the headers, the explanation is 120 lines long, which is lengthy enough to make headers work here, IMO. |
I am not sold on doing this yet. I do see your point that more structure is needed in the explanation. I have tried to explore an alternative above by using headings.
Good point! Sorry I missed this in the RFC. This was already addressed above.
Thanks, another good suggestion. I've added these in my last commit. Let me know if you think that's enough explanation. |
4b94526
to
44c1de6
Compare
It's really good! The "erroneous code example" sentence is still missing but considering the quality of the rest of the error explanation, I think we can exceptionally get over it. Thanks a lot for your work @nham! Now it just remains one last thing: can you squash your commits please? 😃 |
The previous explanation does not seem to explain what it means for an implementation parameter to be used or unused. The new explanation lists the three ways specific ways by which an impl parameter becomes constrained (taken from RFC 447). This also adds a link to RFC 447. The explanation has two different examples. The first is adapted from RFC 447, and shows an instance of E0207 on a impl for a type. The second one is a trait impl example adapted from issue rust-lang#22834. Closes rust-lang#33650
Sure! Squashed |
Thanks! @bors: r+ rollup |
📌 Commit 7d78436 has been approved by |
Improve the long explanation of E0207. The previous explanation does not seem to explain what it means for an implementation parameter to be used or unused. The new explanation lists the three ways specific ways by which an impl parameter becomes constrained (taken from RFC 447). This also adds a link to RFC 447. The explanation has two different examples. The first is adapted from RFC 447, and shows an instance of E0207 on a impl for a type. The second one is a trait impl example adapted from issue rust-lang#22834. Closes rust-lang#33650 cc rust-lang#32777 r? @GuillaumeGomez
Clarify the short explanation of E0207 After being greatly improved in rust-lang#33692, https://doc.rust-lang.org/error-index.html#E0207 uses terminology from the related RFC, which is different from the [reference](https://doc.rust-lang.org/reference/items/implementations.html), e.g. "self type" instead of "implementing type" and "trait reference" instead of "implemented trait". It probably makes no difference to an experienced reader, but for a newbie like me it added to the confusion as you can't look up the definition of the terms being used and can't be sure you've guessed correctly... I would also move the link to RFC to the top, as it seems to be the only doc that attempts to explain what the third criteria entails), but it seems to go against the accepted style.
The previous explanation does not seem to explain what it means for an
implementation parameter to be used or unused. The new explanation lists
the three ways specific ways by which an impl parameter becomes constrained
(taken from RFC 447).
This also adds a link to RFC 447.
The explanation has two different examples. The first is adapted from RFC 447,
and shows an instance of E0207 on a impl for a type. The second one is a trait
impl example adapted from issue #22834.
Closes #33650
cc #32777
r? @GuillaumeGomez