-
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
should_impl_trait - ignore methods with lifetime params #5725
Conversation
r? @yaahc (rust_highfive has picked a reviewer for you, use r? to override) |
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.
Looks good, just needs a changelog:
added to the body of the PR
cc @flip1995
Does this check handle elided lifetimes?
is equivalent to
but will the second form be linted? Also, I think this check should only apply to the next method specifally.
can be moved to a |
The short-circuiting upon lifetime params is a little naive indeed. I'll start by adding a test case for each trait method in the lint method list and see from there. |
I've added a test case for each checked method. All cases can be written with lifetime elision. If the user persists in writing explicitly lifetime params, he'll first hit the needles_lifetime lint. |
It's a check done at hir level. Elided liftetimes are absent from the function declaration struct it seems. |
Three approaches to wrap this pr up:
Any you'd agree with? |
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.
Iterator::next
is a special case. Filter on explicit lifetimes only for that one. Other cases remain unchanged.
Until now, I only remember issues complaining about the next
method. To future prove this fix, you could add another field to the TRAIT_METHODS
list, that specifies if the lint should be skipped, if there are lifetimes defined.
Extra points if you write a doc-comment for this list of tuples, what each field stands for (please :) ).
Sorry for ignoring this PR for so long, I didn't realize, that I was CCed.
88e5dda
to
f300fcd
Compare
I changed the |
3129220
to
d8f898b
Compare
Do you mind if I introduce an exclusion rule for the stderr line count limit? |
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.
Please don't use double underscores for test names. If you want to structure the tests better rather put them in their own directory.
Can you put the tests for this lint in its own directory? There's still an issue with undefined structs in the test cases. |
e3ef2e6
to
f83fad8
Compare
Please remove the |
f83fad8
to
108032e
Compare
@bors r=flip1995,yaahc rollup=always |
📌 Commit 108032e has been approved by |
…95,yaahc should_impl_trait - ignore methods with lifetime params Fixes: rust-lang#5617 changelog: don't lint should_implement_trait when an `Iterator::next` case has explicit parameters
should_impl_trait - ignore methods with lifetime params Fixes: #5617 changelog: don't lint should_implement_trait when an `Iterator::next` case has explicit parameters
💔 Test failed - checks-action_test |
Rollup of 6 pull requests Successful merges: - #5725 (should_impl_trait - ignore methods with lifetime params) - #5837 (needless_collect: catch x: Vec<_> = iter.collect(); x.into_iter() ...) - #5846 (Handle mapping to Option in `map_flatten` lint) - #5848 (Add derive_ord_xor_partial_ord lint) - #5852 (Add lint for duplicate methods of trait bounds) - #5856 (Remove old Symbol reexport) Failed merges: r? @ghost changelog: rollup
Rollup of 6 pull requests Successful merges: - #5725 (should_impl_trait - ignore methods with lifetime params) - #5837 (needless_collect: catch x: Vec<_> = iter.collect(); x.into_iter() ...) - #5846 (Handle mapping to Option in `map_flatten` lint) - #5848 (Add derive_ord_xor_partial_ord lint) - #5852 (Add lint for duplicate methods of trait bounds) - #5856 (Remove old Symbol reexport) Failed merges: r? @ghost changelog: rollup
Please fix the dogfood errors. |
108032e
to
166c520
Compare
2191ec9
to
f9ba829
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.
Thanks! Waiting for rustup
@bors r+ Thanks! |
📌 Commit f9ba829 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes: #5617
changelog: don't lint should_implement_trait when an
Iterator::next
case has explicit parameters