-
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 extra_unused_type_parameters
lint
#10028
Add extra_unused_type_parameters
lint
#10028
Conversation
r? @dswij (rustbot has picked a reviewer for you, use r? to override) |
After some digging, it seems the corresponding hir type was added all the way back in rust-lang/rust#54741 (since renamed to cc-ing @oli-obk |
When you seen an |
Turns out |
This PR is ready for review/merge, I think. |
r? @flip1995 |
Assigning myself, because we talked about this on Zulip a lot. I will probably be busy with release work in the next week, so review might take 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.
Here's an early review. I still have to look at the tests and think a little bit about all the cases I can come up with. Impl looks already really clean AFAICT from a quick glance.
e12dbd7
to
9fdbf4c
Compare
I've found an edge case where the lint doesn't behave quite as expected: fn nested_bounds<A, B, C, D>()
where
B: Iterator<Item = A>,
C: Iterator<Item = B>,
D: Iterator<Item = C>,
{
} This produces the following lint output:
Whereas I would expect the following:
This is because I mark parameters used if they appear in the right-hand side of a where-clause. What I failed to consider, was if the left side also goes unused, then I shouldn't mark the nested parameter as unused. What is the consensus here, should this be fixed? Subsequent applications of the lint will eventually get rid of all of the parameters, but it would be nice if they were all detected at once. However, I feel like that would require a fair bit of engineering effort. |
☔ The latest upstream changes (presumably #9826) made this pull request unmergeable. Please resolve the merge conflicts. |
edfb1a5
to
f3faaeb
Compare
f3faaeb
to
d5785f0
Compare
This is ready for re-review, when you have the time @flip1995 |
☔ The latest upstream changes (presumably #10099) made this pull request unmergeable. Please resolve the merge conflicts. |
d5785f0
to
e6f3cfb
Compare
☔ The latest upstream changes (presumably #10063) made this pull request unmergeable. Please resolve the merge conflicts. |
e6f3cfb
to
e1681e5
Compare
Sorry for taking so long. Last week before vacation in $day_job is a bit stressful. I'll get back to this during the holidays. |
☔ The latest upstream changes (presumably #10098) made this pull request unmergeable. Please resolve the merge conflicts. |
e1681e5
to
f7ebea1
Compare
Will this still be in time to get merged into 1.67? Unsure, since beta has been cut for a while already. |
Sadly not. It would've to get merged today to make it in 1.68. I'm so sorry that I didn't get to review this in time. |
☔ The latest upstream changes (presumably #10206) made this pull request unmergeable. Please resolve the merge conflicts. |
43fdcf5
to
572a014
Compare
☔ The latest upstream changes (presumably #10257) made this pull request unmergeable. Please resolve the merge conflicts. |
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 finally managed to get to this. Looks really good overall. I have some style questions left.
You're concern about those cascading bounds is not an issue we should address. Just applying this lint multiple times is totally fine and pretty much how Clippy works. It's not worth putting in the effort to try and fix this and then potentially introducing FPs or FNs.
self.generics.span.into() | ||
}; | ||
|
||
span_lint_and_help(self.cx, EXTRA_UNUSED_TYPE_PARAMETERS, span, msg, None, help); |
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.
You've put so much effort in crafting this awesome spans and message, I think this should be span_lint_and_sugg
. The non-multispan cases can then be tested with // run-rustfix
in the test file. You'll have to split up the test files for that though: fixable and unfixable.
572a014
to
08e170e
Compare
I've pushed some changes that hopefully address your concerns. It may be a few days before I can get to changing to using Also, I'd like to at some point just squash all these commits before the PR is merged, as I don't think they're super informative on their own. Let me know what you think of the new changes. |
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.
Only one comment left.
We can also just do this in a follow up PR. This is not blocking for this PR.
Sure, I'll wait for that after approving this PR 👍 |
08e170e
to
fba16e2
Compare
I've gone ahead and squashed everything down. Should be ready for merge now. |
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.
Awesome work! Easy to understand code, really concise and well commented+documented. And great suggestion building (one of my favorite parts when working on diagnostics).
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
1 similar comment
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
@flip1995 Thanks for all your help on this work, I really appreciate it! |
Thank you for sticking with it and patiently waiting for my review! |
I now realize it's been pretty much 6 months since I opened the tracking issue for this - I went in with basically zero knowledge about compiler internals, but now I feel a lot better equipped to go off and tackle more work :) |
Sounds great! I would be happy to see more contributions from you to Clippy! But if you want to tackle bigger challenges also have a look at rustc :) |
Closes #9240.
Keeping this as draft for now, because of a bug that I don't know how to fix.It seems that opaque return types are not walked properly, for some unknown reason. As in, the following:This triggers the lint even though it shouldn't. Discussion on Zulip didn't illuminate any possible reasons why, so PR-ing this now to increase visibility.
changelog: new lint: [
extra_unused_type_parameters
]#10028