Skip to content

len_without_is_empty triggers for async len methods, but does not accept async is_empty methods #7232

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

Closed
zesterer opened this issue May 17, 2021 · 4 comments · Fixed by #10359
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@zesterer
Copy link

The following will trigger the len_without_is_empty error:

impl Foo {
    pub async fn len(&self) -> usize { ... }
    pub async fn is_empty(&self) -> bool { ... }
}

It probably shouldn't expect the exact signature fn(&self) -> bool.

@camsteffen camsteffen added C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have labels May 19, 2021
@0xPoe
Copy link
Member

0xPoe commented May 20, 2021

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=79bfeb9fffa256435a1e315490842554

I can't reproduce the issue on rust playground. Could you provide some steps to reproduce it?

@zesterer
Copy link
Author

zesterer commented May 24, 2021

Comment out is_empty. I see no warning. That implies to me that clippy isn't running on the snippet properly.

Actually, this is strange. It doesn't seem to produce this warning at all for async functions, and yet it did when I tested it earlier locally. Has this already been 'fixed'?

@giraffate
Copy link
Contributor

It seems to be fixed by #6980.

@Jarcho
Copy link
Contributor

Jarcho commented Jun 4, 2021

That change basically whitelisted the allowed types for len to an integral type, Option, or Result. Since async functions return impl Future<Output=T> they'll be skipped over. It's a thing I considered adding, just haven't had the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants