-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
#[allow(clippy::single_call_fn)] won't work #12182
Comments
@y21 hey, thanks for the quick fix! Do you think this issue only applies to |
For the majority of the lints (e.g. method calls lints), this sort of issue can't happen, because clippy/rustc correctly considers the lint level attributes when a warning is emitted for the current node being checked. In this specific case, the That said, it does come up every now and then for some lints. I've also been wondering if we can have an internal lint that tries to catch this, but it seems hard to generalize. |
The idea of an internal lint like mentioned above is now tracked over at #12189. |
@y21 I appreciate your description and feedback, that was useful for me to understand the gist of the issue. Also, I think the "linting clippy itself" approach with an internal lint is quite clever! My two cents: the test case you wrote to avoid regression on this issue might be something to add for all the lints (i.e., each lint could have |
Summary
I "enabled"
clippy::single-call-fn
lint via-D clippy::single-call-fn
tocargo clippy
, which expectedly resulted in an error for a single call function, however when I added#[allow(clippy::single_call_fn)]
to the function, the error didn't go away.It does work, however, if I were to add
#![allow(clippy::single_call_fn)]
at the top of themain.rs
.Reproducer
I tried this code:
I expected to see this happen:
Thanks to
#[allow(clippy::single_call_fn)]
,cargo clippy
should give 0 errors.Instead, this happened:
Albeit
#[allow(clippy::single_call_fn)]
,cargo clippy
will still complain as such:Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: