-
Notifications
You must be signed in to change notification settings - Fork 1.7k
expect(len_without_is_empty)
can trigger unfulfilled_lint_expectations
when not enabled
#14597
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
What you are seeing is likely a consequence of the second change in #6853:
In your case, the lint is allowed at the place of the type definition, so it won't trigger. As a workaround, you may want to apply |
@samueltardieu I'm not trying to Moving the |
I understand this. My proposal is only a workaround, as if the lint is allowed on the type (which it is because of |
Yes, the lint is raised on the function definition, which is not located under the |
I've opened a thread on Zulip to discuss the various possibilities. |
`clippy::len_without_is_empty` can be allowed at the type declaration site, and this will prevent the lint from triggering even though the lint is shown on the `len()` method definition. This allows the lint to be expected even though it is allowed at the type declaration site. changelog: [`len_without_is_empty`]: the lint can now be `#[expect]`ed on the `len()` method even when it is `#[allow]`ed on the definining type. Fixes #14597
Summary
Most lints are silent when using
#[expect(some_lint)]
if that lint isn't enabled.However,
len_without_is_empty
seems to be different.#[expect(clippy::len_without_is_empty)]
will trigger a warning if I run clippy with that lint disabled. Even if the affected code does trigger that lint-- it's just seems unhappy about being disabled.Reproducer
This code produces no errors when I run
cargo clippy
:But if I run
cargo clippy -- -Aclippy::all
I get an unexpected warning:This seems strange: there are two lints being
expect
ed here, but only one of them complains when not enabled. As far as I can tell most clippy lints are well-behaved in this condition, and don't trigger warnings whenexpect
ed but disabled.Running clippy with
-Aclippy::all
doesn't seem like a very useful thing to do, and I agree. The thing that I do actually want to do is something like this:... so that I can capture fixes for that particular lint into a standalone commit. And it seems surprising when I get warnings when some unrelated lint was "unfulfilled" in a spurious way.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: