-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Warn unused type parameters #37946
Warn unused type parameters #37946
Conversation
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
|
14cd171
to
f14439d
Compare
I guess that's what I get for testing with |
I'm not sure what the policy is to decide on a new lint, but I do think that this is a useful one -- or at minimum, the error messages you get when you have unused type parameters are terrible. I'm not sure how much this helps though since (as a lint) it gets reported later. I might rather just improve the "unconstrained type parameter" message. @jonathandturner was doing some work on that, I think? |
Nothing from me, so please feel free to take it and run with it. |
☔ The latest upstream changes (presumably #38191) made this pull request unmergeable. Please resolve the merge conflicts. |
f14439d
to
e107d50
Compare
e107d50
to
9604b59
Compare
I would like to get some (any) opinion on this, unlike my last attempt in 2015 which received no comments for a month and closed for inactivity. |
Everyone seems to be on vacation at the moment. |
The code seems ok. We don't really have a clear policy for how to decide whether to add a new lint, do we? I'm not even 100% sure what team is responsible. I don't generally see the compiler team as making "user-facing" decisions of this kind. It could be a @rust-lang/lang decision or perhaps @rust-lang/tools -- have we settled this question in the past? cc @rust-lang/core |
@nikomatsakis I believe that new lints are required to go through an RFC and be approved by the lang team. |
☔ The latest upstream changes (presumably #38533) made this pull request unmergeable. Please resolve the merge conflicts. |
Yes, this is true, as I mentioned on 25871. @sanxiyn as this is a new lint, please open an RFC. Thanks! |
Rebase of #26684. Fix #25871.
Following @huonw's suggestion, warning is disabled for intrinsics and lang items. An example of unused but not incorrect type parameters is
core::intrinsics::size_of
for intrinsics andcore::marker::PhantomData
for lang items.Following @nikomatsakis's suggestion, warning can be silenced by prefixing the underscore as in
_T
. As pointed out,fn _is_sync_send<_T: Sync+Send>() {}
is analogous tofn drop<T>(_x: T) {}
for unused variables.