-
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
Add new multiple_bound_locations
lint
#12259
Add new multiple_bound_locations
lint
#12259
Conversation
9648d17
to
6a8d531
Compare
Fixed CI :) |
☔ The latest upstream changes (presumably #12306) made this pull request unmergeable. Please resolve the merge conflicts. |
6a8d531
to
143bee4
Compare
Fixed conflict. r? @flip1995 |
I won't get to reviewing this in the next 1-2 weeks, as I have a lot on my plate right now (Clippy and day_job), so: r? clippy |
This comment was marked as outdated.
This comment was marked as outdated.
That was unlucky. r? @blyxyas as you are back to reviewing 😅 |
r? @llogiq Sorry for the delay, I was quite sick in the last two weeks. |
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.
As usual, the code looks good (I merely found a typo in the docs), and I'd like more tests. 😉
/// Check if a generic is defined both in the bound predicate and in the `where` clause. | ||
/// | ||
/// ### Why is this bad? | ||
/// It can be confusing for developpers when seeing bounds for a generic in multiple places. |
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 can be confusing for developpers when seeing bounds for a generic in multiple places. | |
/// It can be confusing for developers when seeing bounds for a generic in multiple places. |
Typo
@@ -0,0 +1,24 @@ | |||
#![warn(clippy::multiple_bound_locations)] |
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'd also like to see tests for the various possible combinations of generic impls with generic methods.
e8e666f
to
4dc952c
Compare
Hope you're feeling better. :-/
Fixed the typo and extended tests. |
{ | ||
} | ||
|
||
struct B; |
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.
What if B had generics, say one type and one lifetime, just to mix it up a bit?
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.
Not sure to see what you want to test 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.
Say what if you had struct B<F>(F);
and then an impl<F> B<F> { fn foo(_f: F) -> Self where F: std::fmt::Display { todo!() } }
?
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 won't emit the lint but I can add a check for it if you want?
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.
Added it.
4dc952c
to
6578e56
Compare
|
||
struct C<F>(F); | ||
|
||
impl<F> C<F> { |
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.
What if we had another bound on F here?
Also: Should that even lint? Perhaps it's useful to have a secondary bound for just one method of the impl?
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 have no opinion about this, hence why I didn't add checks on impl blocks. So up to you. :)
6578e56
to
762448b
Compare
And fixed CI. :) |
Thank you! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes #7181.
r? @llogiq
changelog: Add new
multiple_bound_locations
lint