-
Notifications
You must be signed in to change notification settings - Fork 1.9k
wrong_self_convention: fix lint in case of to_*_mut method
#6828
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
wrong_self_convention: fix lint in case of to_*_mut method
#6828
Conversation
|
r? @flip1995 (rust-highfive has picked a reviewer for you, use r? to override) |
flip1995
left a comment
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, except a NIT in the message I don't quite understand the reason.
flip1995
left a comment
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. Just one low hanging fruit, it would be great if you could address this in this PR.
clippy_lints/src/methods/mod.rs
Outdated
| span_lint( | ||
| cx, | ||
| lint, | ||
| first_arg_span, | ||
| &format!( | ||
| "methods called `{}` usually take {}; consider choosing a less ambiguous name", | ||
| conv, | ||
| "{} usually take {}; consider choosing a less ambiguous name", |
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.
While your at it: Could you change this to span_lint_and_help please? The consider choosing a less ambiguous name part should not be in the error message, but in a help message.
c403d14 to
e077208
Compare
|
Another error now: @flip1995 should I somehow make that warning go away, or e.g. split the file? |
|
Just split out the new test cases into a file Also dogfood fails, which isn't run on windows either (for $reasons).
That should be fine. |
5ce0bff to
c6d6431
Compare
|
@rustbot label -S-waiting-on-author +S-waiting-on-review |
|
☔ The latest upstream changes (presumably #6826) made this pull request unmergeable. Please resolve the merge conflicts. |
|
This LGTM now. Unfortunately #6826 was just merged, which moved lints to their own file inside the Or you could pray that git is smart enough to figure this conflict out in a sane way. But I doubt that. If you need help with that or don't want to deal with this conflict, let me know and I can do it for you. |
When a method starts with `to_` and ends with `_mut`, it should expect a `&mut self` parameter, otherwise `&self`.
c6d6431 to
2547edb
Compare
|
Resolved conflicts. Happy to see that refactoring in place! |
|
@bors r+ |
|
📌 Commit 2547edb has been approved by |
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fixes #6758
changelog: wrong_self_convention: fix lint in case of
to_*_mutmethod. When a method starts withto_and ends with_mut, clippy expects a&mut selfparameter, otherwise&self.Any feedback is welcome. I was also thinking if shouldn't we treat
to_the same way asas_. Namely to acceptselftaken:&selfor&mut self.