-
Notifications
You must be signed in to change notification settings - Fork 1.6k
extra_unused_type_parameters probably should not warn empty functions #10319
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
Comments
Hmm, this makes me think about the best way to address this. Obviously, the original intent of the lint here is more-or-less correct, in that the only valid way to use the function is by adding a turbofish. But in this case that concern is irrelevant. It's also a bit difficult to pick exactly which features of the function to check for when turning off the lint. I think maybe a sane choice would be: if a parameter has a bound on it and the function is empty, then don't consider that parameter unused. Of course, the question is how to define if a function is empty - should only the body be empty, or should the function take no arguments as well? I think just checking the body might be the better option here. Open to opinions here - I'm not sure if avoiding false negatives or false positives is more important. |
Triggers false positives. See discussion in rust-lang/rust-clippy#10319. Possibly fixed in rust-lang/rust-clippy#10321. Signed-off-by: Kévin Commaille <[email protected]>
Triggers false positives. See discussion in rust-lang/rust-clippy#10319. Possibly fixed in rust-lang/rust-clippy#10321. Signed-off-by: Kévin Commaille <[email protected]>
Triggers false positives. See discussion in rust-lang/rust-clippy#10319. Possibly fixed in rust-lang/rust-clippy#10321. Signed-off-by: Kévin Commaille <[email protected]>
Summary
It is a popular pattern to define an empty function with an unused type parameter with trait bounds to ensure that the type implements the trait.
extra_unused_type_parameters probably should not warn this pattern (at least by default).
Mentioning @mkrasnitski who implemented this lint in #10028.
Lint Name
extra_unused_type_parameters
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen: no warning
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: