-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Lint also in trait def for wrong_self_convention
#6316
Conversation
r? @ebroto (rust_highfive has picked a reviewer for you, use r? to override) |
dc882a8
to
e408a0c
Compare
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'm hesitating about this... do you think we should only lint if Sized
is a supertrait of the given trait? Otherwise it would not make sense to refer to self
in the error message; OTOH the conventions probably still hold and we should not use those names if we are not following them...
BTW sorry for the long delay in reviewing, I had almost no free time lately
Would you mind opening an issue about it? It would probably make sense to also look into the history of the lints, what were the reasons to split them (if that was the case)? It seems there are no tests for the Thanks! |
Hey @ThibsG, something I can help with? |
I am short on time recently, but I want to find some time to finish this soonish. |
No problem!
😆 |
BTW I checked and it seems to properly lint in required methods. Maybe you changed one of the negative tests? I tried changing the fn from_i32(self); |
Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
e1077ae
to
c456b9e
Compare
You're right, the problem was between the chair and the desk, now it's all good by running the proper test 😅 |
c456b9e
to
90a16e4
Compare
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.
LGTM mostly, but I'm hesitant about assuming that not linting in traits was an oversight.
This lint is one of the oldest ones, and I could not find the original issue or PR that added it to double check if there was a reason to avoid linting in trait defs.
@llogiq I know it's been a while 😄 but do you remember if this was intentional?
@bors r+ Thanks! |
📌 Commit 90a16e4 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Oh you right, thanks @g2p for noting this. |
I double checked the changes made here and this PR doesn't modify the original behavior of the lint. Not really interesting for your mentioned PR, but I agree one test could be added on the trait side, with a trait definition like |
Ensure `Copy` exception in trait definition for `wrong_self_conventio… Add a test case to ensure `Copy` exception is preserved also in trait definition, when passing `self` by value. Follow up of #6316 changelog: none
Extends
wrong_self_convention
to lint also in trait definition.By the way, I think the
wrong_pub_self_convention
example is misleading.On playground, it fires
wrong_self_convention
, so the example (or the lint maybe?) needs to be reworked.The difference with
wrong_self_convention
example is mainly thepub
keyword on the methodas_str
, but the lint doesn't use the function visibility as condition to choose which lint to fire (in fact it uses the visibility of the impl item).fixes: #6307
changelog: Lint
wrong_self_convention
lint in trait def also