-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Extend E0106, E0261 #57310
Extend E0106, E0261 #57310
Conversation
Added an example that points out hardly obvious mistake one could make when writing impl for a new type.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (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. |
src/librustc/diagnostics.rs
Outdated
@@ -772,6 +776,24 @@ struct Foo<'a> { | |||
x: &'a str, | |||
} | |||
``` | |||
|
|||
Implementations need their own lifetime declarations: |
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.
Doc suggestion:
Impl blocks declare lifetime parameters separately. You need to add lifetime parameters to an impl block if you're implementing a type that has a lifetime parameter of its own. For example:
src/librustc/diagnostics.rs
Outdated
|
||
Implementations need their own lifetime declarations: | ||
|
||
``` |
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.
Since these code blocks stand on their own, can you make sure to tag them with compile_fail,E0261
like the other failing sample in this excerpt? You'll also need to include the struct definition again.
Which are declared like this: | ||
|
||
``` | ||
// correct |
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.
These code samples are tested, so please include the struct definition in this sample to make sure it properly compiles.
cc @rust-lang/docs in case someone else wants to take a look. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Replaced impl block dock with suggested one and made sure that blocks compile.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
We have a linter that checks for trailing whitespace in files. Can you check out these lines and trim off the trailing whitespace there? |
ping from triage @purple-ice any updates? |
Since the author has deleted their fork, i've checked out their changes, applied fixes to review comments, and reopened it as #57950. I'll close this PR since the new one includes all the changes from this one. |
…r=estebank Extend E0106, E0261 This is a reopening of rust-lang#57310 with review comments addressed because the original author has since deleted their fork. From the author (@purple-ice): > Added an example that points out hardly obvious mistake one could make when writing impl for a new type. r? @rust-lang/docs
Added an example that points out hardly obvious mistake one could make when writing impl for a new type.